private static void OnAutoSizeChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { var column = (ColumnBase)obj; if ((bool)e.NewValue) { column.PropertyChanged += column_PropertyChanged; if (column.DataGridControl != null) { string valuePath = GetValuePath(column); if (valuePath != null) { SetWidthToFit(column); ItemPropertyChangedListener.Subscribe(column, column.DataGridControl.Items, valuePath, DataGridControl_ItemsChanged); } } } else { column.PropertyChanged -= column_PropertyChanged; if (column.DataGridControl != null) { ItemPropertyChangedListener.Unsubscribe(column); } } }
private static void OnAutoSizeChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { var comboBox = (ComboBox)obj; if ((bool)e.NewValue) { SetWidthToFit(comboBox); ItemPropertyChangedListener.Subscribe(comboBox, comboBox.Items, comboBox.DisplayMemberPath, ComboBox_ItemsChanged); } else { ItemPropertyChangedListener.Unsubscribe(comboBox); } }
private static void column_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "DataGridControl") { var column = (ColumnBase)sender; if (column.DataGridControl != null) { string valuePath = GetValuePath(column); if (valuePath != null) { SetWidthToFit(column); ItemPropertyChangedListener.Subscribe(column, column.DataGridControl.Items, valuePath, DataGridControl_ItemsChanged); } } else { ItemPropertyChangedListener.Unsubscribe(column); } } }