diff options
author | Bertrand Le Roy <beleroy@microsoft.com> | 2019-01-12 00:53:32 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-12 00:53:32 +0300 |
commit | b681699b6e9fefb80c55388fcb25a571fecd6160 (patch) | |
tree | 9829b365333b335a6da1170ac4d0136f36ef1121 /Xamarin.PropertyEditing.Windows | |
parent | 1ef475122d564e714f51a3bb61e69e90b992e544 (diff) | |
parent | af0feca598a687e9c997229af264fb5bddbf9701 (diff) |
Merge pull request #494 from xamarin/ermau-fix-noeditors
[Win] Don't bind with no name category
Diffstat (limited to 'Xamarin.PropertyEditing.Windows')
-rw-r--r-- | Xamarin.PropertyEditing.Windows/PropertyEditorPanel.cs | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/Xamarin.PropertyEditing.Windows/PropertyEditorPanel.cs b/Xamarin.PropertyEditing.Windows/PropertyEditorPanel.cs index 7355e6e..267390f 100644 --- a/Xamarin.PropertyEditing.Windows/PropertyEditorPanel.cs +++ b/Xamarin.PropertyEditing.Windows/PropertyEditorPanel.cs @@ -70,7 +70,7 @@ namespace Xamarin.PropertyEditing.Windows } public static readonly DependencyProperty ArrangeModeProperty = DependencyProperty.Register ( - nameof(ArrangeMode), typeof(PropertyArrangeMode), typeof(PropertyEditorPanel), new PropertyMetadata (PropertyArrangeMode.Name, (o, args) => ((PropertyEditorPanel)o).OnArrangeModeChanged ((PropertyArrangeMode)args.NewValue))); + nameof(ArrangeMode), typeof(PropertyArrangeMode), typeof(PropertyEditorPanel), new PropertyMetadata (PropertyArrangeMode.Name, (o, args) => ((PropertyEditorPanel)o).UpdateBinding ((PropertyArrangeMode)args.NewValue))); public PropertyArrangeMode ArrangeMode { @@ -103,7 +103,7 @@ namespace Xamarin.PropertyEditing.Windows OnTargetPlatformChanged(); if (this.vm.SelectedObjects.Count > 0 || ArrangeMode != PropertyArrangeMode.Name) - OnArrangeModeChanged (ArrangeMode); + UpdateBinding (ArrangeMode); } private FrameworkElement root; @@ -154,7 +154,7 @@ namespace Xamarin.PropertyEditing.Windows } if (ArrangeMode == PropertyArrangeMode.Name) - OnArrangeModeChanged (ArrangeMode); + UpdateBinding (ArrangeMode); UpdateIcon (); } @@ -203,21 +203,25 @@ namespace Xamarin.PropertyEditing.Windows SetCurrentValue (ArrangeModeProperty, this.vm.ArrangeMode); } - private void OnArrangeModeChanged (PropertyArrangeMode newMode) + private void UpdateBinding (PropertyArrangeMode arrangeMode) { if (this.items == null) return; - Binding itemsSource; - if (newMode == PropertyArrangeMode.Name) - itemsSource = new Binding ("ArrangedEditors[0].Editors"); - else + Binding itemsSource = null; + if (arrangeMode == PropertyArrangeMode.Name) { + if (SelectedItems.Count > 0) + itemsSource = new Binding ("ArrangedEditors[0].Editors") { FallbackValue = null }; + } else itemsSource = new Binding ("ArrangedEditors"); - this.items.SetBinding (ItemsControl.ItemsSourceProperty, itemsSource); + if (itemsSource != null) + this.items.SetBinding (ItemsControl.ItemsSourceProperty, itemsSource); + else + this.items.ItemsSource = null; if (this.vm != null) - this.vm.ArrangeMode = newMode; + this.vm.ArrangeMode = arrangeMode; } } |