-
Notifications
You must be signed in to change notification settings - Fork 697
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
DataTemplateSelector for TreeView does not show nested items #994
Comments
Does the tree view item need the selector as well? |
Ok, I've fixed this after a few hours and looking at the XAML Controls Gallery source. The issue is the override method used in DataTemplateSelector;
I was overriding that method. If I override the other overload of
Looks like there might be a bug in the overload with the |
I believe the two-parameter SelectTemplateCore is deprecated and never called ... @ranjeshj to confirm. We should figure out how to document this better, for sure. |
That is correct. The override which passes the container is deprecated. Also in this case, the container is in the template that you are creating now so you cannot get the container passed to you. |
Describe the bug
I have noticed a weird behavior using a DataTemplateSelector for a treeview.
See screenshot #1 for the expected behavior.
I went and looked at the XAML Controls Gallery and note that the DataTemplateSelector is set up differently; I would still expect this to work how I've done it.
Steps to reproduce the bug
Here is the code which works as expected:
I have tried to create a DataTemplateSelector as follows:
Treeview is defined in XAML as:
The data template selector code is as follows:
NOTE: Creating a new instance of Templates each time the template is selected and returning from that instance shows the same result.
The class
Templates
is a XAML (with codebehind) ResourceDictionary:Expected behavior
I would expect that using the resource dictionary & DataTemplateSelector to have the same UI and behavior as doing it directly in XAML.
See Screenshot #2 for how it appears.
Screenshots
Screenshot #1 - expected behavior, as seen when the data template is defined locally without a DataTemplateSelector
Screenshot #2 - how it appears using the DataTemplateSelector. Note the lack of children:
Version Info
Using Win10 1903, not using MUX explicitly.
The text was updated successfully, but these errors were encountered: