-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Add bindable DP TreeListView.SelectedItems
#3849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add bindable DP TreeListView.SelectedItems
#3849
Conversation
…ng state when collapsing items. Tests are missing
…d even if the parent node is collapsed
if (dataContext is TreeListViewDataBinding viewModelA) | ||
{ | ||
Assert.Equal(2, viewModelA.SelectedItems.Count); | ||
} | ||
if (dataContext is TreeListViewImplicitTemplate viewModelB) | ||
{ | ||
Assert.Equal(2, viewModelB.SelectedItems.Count); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test tests 2 different UserControls with 2 different ViewModels. I somehow have to access the ViewModels. I know putting if-conditions in tests is not a good idea, but I opted to go this way.
Alternatively I could have created an interface to expose the SelectedItems
property, but I think adding an interface just for the purpose of this test is a bit too much.
Other opinions/thoughts are welcome.
Fixing minor code issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is starting to look good. I pushed up a few minor changes and some failing tests that we probably want to address.
…w_CollapsingParentAndMovingSelection_ClearsSelectionsFromHiddenChildNode")
The only thing left to solve is dealing with the correct selection of duplicate items. At least this is the last and only failing test ( So far I was unable to find a solution for this. Keeping track of the selected items via reference (that's how it currently works) clearly doesn't work with duplicate items. I was trying to make it work by keeping track of the selected item(s) via their index. This however also doesn't work since the |
This adds a DP called
SelectedItems
to theTreeListView
control.There was a small hurdle to overcome, because of the
TreeListView
s impl., which adds (when expanding) and deletes (when collapsing) childs.Bascially internally there are now 2
SelectedItems
Lists:base.SelectedItems
(inherited fromListView
) which only contains the visually selected itemsSelectedItems
(Dependency property) which always contains all of the selected items. This is the one the consumers see/use.I also added tests for this new DP and showcases to the MD2&3 demos.