private void Datas_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { if (string.IsNullOrEmpty(FilterText)) { this.DisplayWindows.Clear(); ProgramData.Datas.ToList().ForEach(data => DisplayWindows.Add(data)); ProgramData.HideWindowData.ToList().ForEach(data => DisplayWindows.Add(data)); } }
public ListWindowViewModel() { this.ProgramData = ProgramData.Instance; DeleteWindowCommand = new RelayCommand <WindowsData>(DeleteWindowClick); ChangeWindowVisibilityCommand = new RelayCommand <WindowsData>(ChangeWindowVisibilityMethod); NewWindowCommand = new RelayCommand(NewWindowMethod); FilterTextChangedCommand = new RelayCommand <TextChangedEventArgs>(FilterTextChangedMethod); ProgramData.Datas.ToList().ForEach(data => DisplayWindows.Add(data)); ProgramData.HideWindowData.ToList().ForEach(data => DisplayWindows.Add(data)); ProgramData.Datas.CollectionChanged += Datas_CollectionChanged; ProgramData.HideWindowData.CollectionChanged += Datas_CollectionChanged; }
private void FilterTextChangedMethod(TextChangedEventArgs e) { var text = (e.Source as System.Windows.Controls.TextBox).Text; this.DisplayWindows.Clear(); this.ProgramData.Datas?.ToList()?.Where(it => it.RichTextBoxContent.Contains(text))?.ToList()?.ForEach(data => DisplayWindows.Add(data)); this.ProgramData.HideWindowData?.ToList()?.Where(it => it.RichTextBoxContent.Contains(text))?.ToList()?.ForEach(data => DisplayWindows.Add(data)); }