Skip to content

Commit

Permalink
Add IsSelected
Browse files Browse the repository at this point in the history
  • Loading branch information
erri120 committed Sep 12, 2024
1 parent 1bc55cd commit 8fecafc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/NexusMods.App.UI/Controls/TreeDataGrid/TreeDataGridAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,18 @@ protected TreeDataGridAdapter()
self._selectionModelsSerialDisposable.Disposable = selectionObservable.Subscribe(self, static (eventArgs, self) =>
{
self.SelectedModels.RemoveRange(eventArgs.DeselectedItems.NotNull());
foreach (var item in eventArgs.DeselectedItems)
{
if (item is null) continue;
item.IsSelected.Value = false;
}

self.SelectedModels.AddRange(eventArgs.SelectedItems.NotNull());
foreach (var item in eventArgs.SelectedItems)
{
if (item is null) continue;
item.IsSelected.Value = true;
}
});

self.Source.Value = source;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class TreeDataGridItemModel<TModel, TKey> : TreeDataGridItemModel
where TModel : TreeDataGridItemModel<TModel, TKey>
where TKey : notnull
{
public ReactiveProperty<bool> IsSelected { get; } = new(value: false);

public IObservable<bool> HasChildrenObservable { get; init; } = Observable.Return(false);
public BindableReactiveProperty<bool> HasChildren { get; } = new();

Expand Down Expand Up @@ -130,7 +132,8 @@ protected override void Dispose(bool disposing)
_modelActivationDisposable,
_childrenObservableSerialDisposable,
_childrenCollectionInitializationSerialDisposable,
HasChildren
HasChildren,
IsSelected
);
}

Expand Down

0 comments on commit 8fecafc

Please sign in to comment.