Use SourceCache, set SelectedItem and scroll to it

This commit is contained in:
2022-05-25 08:52:07 +02:00
parent d94d198344
commit 06f79ddfa9
14 changed files with 112 additions and 53 deletions

View File

@@ -47,6 +47,56 @@ public partial class BindedCollection<T> : IDisposable, INotifyPropertyChanged
});
}
public void Dispose()
{
_disposable?.Dispose();
_innerDisposable?.Dispose();
GC.SuppressFinalize(this);
}
}
public partial class BindedCollection<T, TKey> : IDisposable, INotifyPropertyChanged where TKey : notnull
{
private readonly IDisposable? _disposable;
private IDisposable? _innerDisposable;
[Notify] private ReadOnlyObservableCollection<T>? _collection;
public BindedCollection()
{
}
public BindedCollection(IObservable<IChangeSet<T, TKey>> dynamicList)
{
_disposable = dynamicList
.Bind(out var collection)
.DisposeMany()
.Subscribe();
_collection = collection;
}
public BindedCollection(IObservable<IObservable<IChangeSet<T, TKey>>?> dynamicListSource)
{
_disposable = dynamicListSource.Subscribe(dynamicList =>
{
_innerDisposable?.Dispose();
if (dynamicList is not null)
{
_innerDisposable = dynamicList
.Bind(out var collection)
.DisposeMany()
.Subscribe();
Collection = collection;
}
else
{
Collection = null;
}
});
}
public void Dispose()
{
_disposable?.Dispose();

View File

@@ -14,13 +14,13 @@ public interface ITabViewModel : IInitable<ITab, int>, IDisposable
IObservable<bool> IsSelected { get; }
IObservable<IContainer?> CurrentLocation { get; }
IObservable<IItemViewModel?> CurrentSelectedItem { get; }
IObservable<IObservable<IChangeSet<IItemViewModel>>?> CurrentItems { get; }
IObservable<IObservable<IChangeSet<IItemViewModel, string>>?> CurrentItems { get; }
IObservable<IChangeSet<FullName>> MarkedItems { get; }
IObservable<IObservable<IChangeSet<IItemViewModel>>?> SelectedsChildren { get; }
IObservable<IObservable<IChangeSet<IItemViewModel>>?> ParentsChildren { get; }
BindedCollection<IItemViewModel>? CurrentItemsCollection { get; }
BindedCollection<IItemViewModel>? SelectedsChildrenCollection { get; }
BindedCollection<IItemViewModel>? ParentsChildrenCollection { get; }
IObservable<IObservable<IChangeSet<IItemViewModel, string>>?> SelectedsChildren { get; }
IObservable<IObservable<IChangeSet<IItemViewModel, string>>?> ParentsChildren { get; }
BindedCollection<IItemViewModel, string>? CurrentItemsCollection { get; }
BindedCollection<IItemViewModel, string>? SelectedsChildrenCollection { get; }
BindedCollection<IItemViewModel, string>? ParentsChildrenCollection { get; }
IObservable<IReadOnlyCollection<IItemViewModel>?> CurrentItemsCollectionObservable { get; }
IObservable<IReadOnlyCollection<IItemViewModel>?> ParentsChildrenCollectionObservable { get; }
IObservable<IReadOnlyCollection<IItemViewModel>?> SelectedsChildrenCollectionObservable { get; }