Blacker.MangaScraper.Helpers.ListBoxExtension.OnSelectedItemsSourceChanged C# (CSharp) Method

OnSelectedItemsSourceChanged() private static method

private static OnSelectedItemsSourceChanged ( DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e ) : void
d System.Windows.DependencyObject
e System.Windows.DependencyPropertyChangedEventArgs
return void
        private static void OnSelectedItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ListBox listBox = d as ListBox;
            if (listBox == null)

                throw new InvalidOperationException("The ListBoxExtension.SelectedItemsSource attached property can only be applied to ListBox controls.");

            listBox.SelectionChanged -= new SelectionChangedEventHandler(OnListBoxSelectionChanged);
            if (e.NewValue != null)
            {
                ListenForChanges(listBox);
            }
        }