public ListBoxMultiUpdatePropertyNamesBehavior(System.Windows.Controls.ListBox listBox) { this._listBox = listBox; //存储原先的SelectedItem _previousSelectedItem = listBox.SelectedItem; listBox.SelectionChanged += listBox_SelectionChanged; //UnLoad时候,释放存储的资源,否则内存会泄露 UIThread.BeginInvoke(new Action(() => { var container = _listBox.FindAncestor <TabbedMdiContainer>(); if (container != null) { container.SelectedWindow.Unloaded += SelectedWindow_Unloaded; } }), DispatcherPriority.Render); }
public ListBoxMultiUpdatePropertyNamesBehavior(System.Windows.Controls.ListBox listBox) { this._listBox = listBox; //存储原先的SelectedItem _previousSelectedItem = listBox.SelectedItem; listBox.SelectionChanged += listBox_SelectionChanged; //UnLoad时候,释放存储的资源,否则内存会泄露 UIThread.BeginInvoke(new Action(() => { var container = _listBox.FindAncestor<TabbedMdiContainer>(); if (container != null) container.SelectedWindow.Unloaded += SelectedWindow_Unloaded; }), DispatcherPriority.Render); }