diff options
Diffstat (limited to 'Xamarin.PropertyEditing/ViewModels/CollectionPropertyViewModel.cs')
-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) |