Fixed issue when locking and unlocking the same wallet

This commit is contained in:
TheXamlGuy
2024-07-12 20:13:26 +01:00
parent bb90015092
commit 419f27a932
+17 -1
View File
@@ -144,13 +144,22 @@ public partial class ObservableCollection<TItem> :
} }
} }
public void SetSource(IList<TItem> source) private Func<TItem> defaultSelectionFactory;
public void SetSource(IList<TItem> source,
Func<TItem>? defaultSelectionFactory)
{ {
foreach (TItem item in source) foreach (TItem item in source)
{ {
Add(item); Add(item);
} }
if (defaultSelectionFactory is not null)
{
this.defaultSelectionFactory = defaultSelectionFactory;
SelectedItem = defaultSelectionFactory.Invoke();
}
if (source is INotifyCollectionChanged observableSource) if (source is INotifyCollectionChanged observableSource)
{ {
observableSource.CollectionChanged -= SourceCollectionChanged; observableSource.CollectionChanged -= SourceCollectionChanged;
@@ -193,6 +202,11 @@ public partial class ObservableCollection<TItem> :
{ {
Add(item); Add(item);
} }
if (defaultSelectionFactory is not null)
{
SelectedItem = defaultSelectionFactory.Invoke();
}
} }
break; break;
} }
@@ -266,6 +280,8 @@ public partial class ObservableCollection<TItem> :
public void Reset(Action<ObservableCollection<TItem>> factory, bool disposeItems = true) public void Reset(Action<ObservableCollection<TItem>> factory, bool disposeItems = true)
{ {
SelectedItem = default;
Clear(disposeItems); Clear(disposeItems);
factory.Invoke(this); factory.Invoke(this);
} }