/// <summary> /// Handles a change to the Column property. /// </summary> /// <param name="dependencyObject">The object that originated the event.</param> /// <param name="dependencyPropertyChangedEventArgs">The property change event arguments.</param> static void OnColumnPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs) { // Extract the ColumnViewColumnHeader and the property from the generic event arguments. ColumnViewColumnHeader columnViewColumnHeader = dependencyObject as ColumnViewColumnHeader; ColumnViewColumn columnViewColumn = dependencyPropertyChangedEventArgs.NewValue as ColumnViewColumn; // This will force the sorting properties to reflect the sort order of the underlying column. columnViewColumnHeader.UpdateSortDirection(); // This will keep the header property 'HasFilters' reconciled to the same property in the column it represents. columnViewColumnHeader.SetValue(ColumnViewColumnHeader.hasFiltersPropertyKey, columnViewColumnHeader.Column.HasFilters); }
/// <summary> /// Handles a change to the dependency properties. /// </summary> /// <param name="dependencyObject">The object that originated the event.</param> /// <param name="dependencyPropertyChangedEventArgs">The event arguments.</param> static void OnIsSelectedPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs) { // The filter is closed when the selection is turned off. The selection is a property that combines the keystrokes and the mouse gestures into a single // state the shows the menu header has been selected by the user for some operation. The visual cues for the header are driven by this property and so // is the state of the filter drop down. ColumnViewColumnHeader columnViewColumnHeader = dependencyObject as ColumnViewColumnHeader; if ((Boolean)dependencyPropertyChangedEventArgs.OldValue) { if (columnViewColumnHeader.IsFilterOpen) { columnViewColumnHeader.SetValue(ColumnViewColumnHeader.IsFilterOpenProperty, false); } } }