Microsoft.Silverlight.Testing.Controls.TreeViewItem.OnIsSelectionActivePropertyChanged C# (CSharp) Method

OnIsSelectionActivePropertyChanged() private static method

IsSelectionActiveProperty property changed handler.
private static OnIsSelectionActivePropertyChanged ( DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e ) : void
d System.Windows.DependencyObject TreeViewItem that changed its IsSelectionActive.
e System.Windows.DependencyPropertyChangedEventArgs Event arguments.
return void
        private static void OnIsSelectionActivePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            TreeViewItem source = d as TreeViewItem;

            // Ignore the change if requested
            if (source.IgnorePropertyChange)
            {
                source.IgnorePropertyChange = false;
                return;
            }

            // Ensure the property is only written when expected
            if (!source._allowWrite)
            {
                // Reset the old value before it was incorrectly written
                source.IgnorePropertyChange = true;
                source.SetValue(IsSelectionActiveProperty, e.OldValue);

                throw new InvalidOperationException();
            }

            source.UpdateVisualState(true);
        }