void OnPropertyListSelectionChanged(object sender, SelectionChangedEventArgs e) { this.selectedProperties = this.propertyList.SelectedItems.OfType <ThemeProperty>().ToList(); if (this.Editor != null) { this.Editor.ValueChanged -= OnEditorValueChanged; } PropertyEditor editor; if (this.selectedProperties.Count == 0) { editor = this.nothingSelectedEditor; } else if (this.selectedProperties.Any(p => p.PropertyInfo.PropertyType != this.selectedProperties[0].PropertyInfo.PropertyType)) { editor = this.incompatibleTypesEditor; } else { if (!this.editorTable.TryGetValue(this.selectedProperties[0].PropertyInfo.PropertyType, out editor)) { editor = new GenericPropertyEditor(); this.editorTable[this.selectedProperties[0].PropertyInfo.PropertyType] = editor; } } this.Editor = editor; if (this.selectedProperties.Count == 1) { object value = null; // Only set the editor's value if this is the only property selected if (this.selectedProperties[0].PropertyInfo.PropertyType == typeof(Color)) { var dp = Theme.Instance.Theme.LookupThemeProperty(this.selectedProperties[0].PropertyInfo.Name); var binding = BindingOperations.GetBinding(Theme.Instance.Theme, dp); if (binding != null && binding.Source is PaletteColor) { value = binding.Source; } } if (value == null) { value = this.selectedProperties[0].PropertyInfo.GetValue(this.ThemeObject, null); } editor.Value = value; } this.Editor.ValueChanged += OnEditorValueChanged; }
void OnPropertyListSelectionChanged(object sender, SelectionChangedEventArgs e) { this.selectedProperties = this.propertyList.SelectedItems.OfType<ThemeProperty>().ToList(); if (this.Editor != null) { this.Editor.ValueChanged -= OnEditorValueChanged; } PropertyEditor editor; if (this.selectedProperties.Count == 0) { editor = this.nothingSelectedEditor; } else if (this.selectedProperties.Any(p => p.PropertyInfo.PropertyType != this.selectedProperties[0].PropertyInfo.PropertyType)) { editor = this.incompatibleTypesEditor; } else { if (!this.editorTable.TryGetValue(this.selectedProperties[0].PropertyInfo.PropertyType, out editor)) { editor = new GenericPropertyEditor(); this.editorTable[this.selectedProperties[0].PropertyInfo.PropertyType] = editor; } } this.Editor = editor; if (this.selectedProperties.Count == 1) { object value = null; // Only set the editor's value if this is the only property selected if (this.selectedProperties[0].PropertyInfo.PropertyType == typeof(Color)) { var dp = Theme.Instance.Theme.LookupThemeProperty(this.selectedProperties[0].PropertyInfo.Name); var binding = BindingOperations.GetBinding(Theme.Instance.Theme, dp); if (binding != null && binding.Source is PaletteColor) { value = binding.Source; } } if (value == null) { value = this.selectedProperties[0].PropertyInfo.GetValue(this.ThemeObject, null); } editor.Value = value; } this.Editor.ValueChanged += OnEditorValueChanged; }