private static void OnDataContextChanged(SearchListView view, object sender, DependencyPropertyChangedEventArgs args) { var dc = args.NewValue as SearchListViewModel; if (dc == null) return; var selectedChangedListener = new WeakEventListener<SearchListView, SearchListViewModel, SelectedChangedEventArgs>(view, dc); dc.SelectedChanged += selectedChangedListener.OnEvent; selectedChangedListener.OnEventAction = OnSelectedChanged; selectedChangedListener.OnDetachAction = OnDetachSelectedChanged; }
private static void OnDetachDataContextChanged(WeakEventListener<SearchListView, SearchListView, DependencyPropertyChangedEventArgs> listener, SearchListView source) { source.DataContextChanged -= listener.OnEvent; }
private static void OnSelectedChanged(SearchListView view, object sender, SelectedChangedEventArgs args) { if (args.IsSelected) view.SearchList.Rebind(); }