diff options
author | Eric Maupin <ermaup@microsoft.com> | 2019-03-07 23:31:18 +0300 |
---|---|---|
committer | Eric Maupin <ermaup@microsoft.com> | 2019-03-07 23:31:18 +0300 |
commit | d9e7bd9e8201c9d9bd688ed007e70b3e47b45930 (patch) | |
tree | 84bfbdb824c4e11e29cac178e520c11920a64efd /Xamarin.PropertyEditing | |
parent | 15742191d7400b0a0a0153d202a735d3f2955737 (diff) |
[Core] Improve selected target handling
Diffstat (limited to 'Xamarin.PropertyEditing')
-rw-r--r-- | Xamarin.PropertyEditing/ViewModels/CollectionPropertyViewModel.cs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Xamarin.PropertyEditing/ViewModels/CollectionPropertyViewModel.cs b/Xamarin.PropertyEditing/ViewModels/CollectionPropertyViewModel.cs index f383e66..c833a6f 100644 --- a/Xamarin.PropertyEditing/ViewModels/CollectionPropertyViewModel.cs +++ b/Xamarin.PropertyEditing/ViewModels/CollectionPropertyViewModel.cs @@ -76,6 +76,8 @@ namespace Xamarin.PropertyEditing.ViewModels RequestTypes (); this.collectionView.CollectionChanged += OnCollectionViewContentsChanged; + + UpdateSelectedTarget (); } public event EventHandler<TypeRequestedEventArgs> TypeRequested; @@ -198,6 +200,9 @@ namespace Xamarin.PropertyEditing.ViewModels this.collectionView.Reset (await GetViewsFromValueAsync()); else this.collectionView.Clear(); + + if (Panel != null) + UpdateSelectedTarget(); } protected override void OnEditorsChanged (object sender, NotifyCollectionChangedEventArgs e) @@ -312,6 +317,15 @@ namespace Xamarin.PropertyEditing.ViewModels return items; } + private void UpdateSelectedTarget () + { + if (SelectedTarget != null) + SelectedTarget = this.collectionView.FirstOrDefault (ivm => Equals (ivm.Item, SelectedTarget.Item)); + + if (SelectedTarget == null && Targets.Count > 0) + SelectedTarget = Targets[0]; + } + private async void RequestTypes () { if (Property == null) |