[Core] Ensure new object reuses view models
This commit is contained in:
Родитель
6a6761eb9b
Коммит
687934e61a
|
@ -107,6 +107,21 @@ namespace Xamarin.PropertyEditing
|
|||
self.Add (with);
|
||||
}
|
||||
|
||||
public static void Reset<T> (this ICollection<T> self, IEnumerable<T> newContents)
|
||||
{
|
||||
if (self == null)
|
||||
throw new ArgumentNullException (nameof(self));
|
||||
if (newContents == null)
|
||||
throw new ArgumentNullException (nameof(newContents));
|
||||
|
||||
if (self is ObservableCollectionEx<T> oce) {
|
||||
oce.Reset (newContents);
|
||||
} else {
|
||||
self.Clear();
|
||||
self.AddItems (newContents);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Move (this IList self, int index, int moveTo)
|
||||
{
|
||||
if (self == null)
|
||||
|
|
|
@ -90,13 +90,16 @@ namespace Xamarin.PropertyEditing.ViewModels
|
|||
return;
|
||||
|
||||
using (await AsyncWork.RequestAsyncWork (this)) {
|
||||
ValueModel.SelectedObjects.Clear();
|
||||
|
||||
|
||||
await base.UpdateCurrentValueAsync ();
|
||||
ValueType = CurrentValue?.ValueDescriptor as ITypeInfo;
|
||||
|
||||
if (CurrentValue?.Value != null)
|
||||
ValueModel.SelectedObjects.Add (CurrentValue.Value);
|
||||
if (CurrentValue?.Value != null) {
|
||||
ValueModel.SelectedObjects.Reset (new[] { CurrentValue.Value });
|
||||
} else {
|
||||
ValueModel.SelectedObjects.Clear ();
|
||||
}
|
||||
|
||||
SetCanDelve (ValueModel.SelectedObjects.Count > 0);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче