private static void OnEnumValuePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { EnumComboBox combobox = d as EnumComboBox; if (e.NewValue == null) { return; } if (combobox.ItemsSource == null || !EqualityComparer <Type> .Default.Equals(e.NewValue?.GetType(), combobox._type)) { combobox._type = e.NewValue?.GetType(); combobox.InitItemsSourceFromType(e.NewValue.GetType()); int newIndex = Array.IndexOf(combobox.enumsList, e.NewValue); if (combobox.SelectedIndex != newIndex) { combobox.SelectedIndex = newIndex; } } }
public static object GetEnumValue(EnumComboBox element) { return((object)element.GetValue(EnumValueProperty)); }
public static void SetEnumValue(EnumComboBox element, object value) { element.SetValue(EnumValueProperty, value); }