/// <summary> /// Handles a change to the Width property. /// </summary> /// <param name="dependencyObject">The owner of the property.</param> /// <param name="dependencyPropertyChangedEventArgs">The event arguments.</param> static void OnWidthChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs) { // If the column width is set to Double.NaN then we need to auto size the column. Otherwise the column is given a specific width for all rows. ColumnViewColumn columnViewColumn = dependencyObject as ColumnViewColumn; columnViewColumn.OnPropertyChanged(WidthProperty.Name); }
/// <summary> /// Handles a change to a generic property. /// </summary> /// <param name="dependencyObject">The Object that originated the event.</param> /// <param name="dependencyPropertyChangedEventArgs">The property change event arguments.</param> static void OnPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs) { // This will raise the INotifyPropertyChange event for any of the generic properties attached to this handler. ColumnViewColumn columnViewColumn = dependencyObject as ColumnViewColumn; columnViewColumn.OnPropertyChanged(dependencyPropertyChangedEventArgs.Property.Name); // This will provide a default value for the description when a string header is defined. The designer can always override it with an explicit // description of the column. The description shows up in the context menu and the 'Choose Column Details' dialog box. if (dependencyPropertyChangedEventArgs.Property == ColumnViewColumn.HeaderProperty) { String headerText = dependencyPropertyChangedEventArgs.NewValue as String; if (headerText != null && columnViewColumn.Description == null) { columnViewColumn.Description = headerText; } } }