Microsoft-ui-xaml: Proposal: Make TreeView.SelectedItem a DependencyProperty

Created on 16 May 2020  路  10Comments  路  Source: microsoft/microsoft-ui-xaml

Proposal: Make TreeView.SelectedItem a DependencyProperty

Summary

The TreeView.SelectedItem property is not a DP, hence it is not possible to bind to the view model with the TwoWay mode.

Rationale

One common pattern for a list or tree view is the master detail pattern. The user selects an item from an items view (ListView, ComboBox, ListBox, TreeView etc.) and in a secondary view more details for the given item are presented, for example the body of an email, the content of a directory or the article of an rss feed. In order for the view model to retrieve the selected email from the server, it must know if and which email was selected in the list/tree.
In most, if not all, other items controls, the SelectedItem property is infact a DependencyProperty.

area-TreeView feature proposal team-Controls

Most helpful comment

I really like your open source spirit. I had a similar issue with WPF a few years ago. But I would never have thought of reporting this. I would not have even known where. And here it was solved in less than two weeks. Thank you very much!

All 10 comments

I am all for this proposal, I spent quite a few minutes trying to understand why my binding was not working until I found out it is not in fact a dependency property 馃榾

Yes, this should definitely be a DP in my opinion.
If this proposal get's accepted, I think it would be pretty straightforward to implement.

Yes please

@MikeHillberg graciously offered to do the spec work for this. Thanks! @dpaulino/@chingucoding, would one of you be able to create a PR ?

If @dpaulino does not want to create a PR I would step in, but I'll leave it up to @dpaulino to decide :)

@chingucoding unfortunately don't have bandwidth this week. Please feel free to take this Marcel

Right, will do. Thanks.

While we are at it, should SelectedNode also become a DP?

SelectedItem is definitely useful as a dependency property so that it can be bound. I'm not sure if there is much use making SelectedNode a dependency property. I might be wrong.

I really like your open source spirit. I had a similar issue with WPF a few years ago. But I would never have thought of reporting this. I would not have even known where. And here it was solved in less than two weeks. Thank you very much!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mrlacey picture mrlacey  路  3Comments

MartinZikmund picture MartinZikmund  路  3Comments

ratishphilip picture ratishphilip  路  3Comments

ocalvo picture ocalvo  路  3Comments

adrientetar picture adrientetar  路  3Comments