WPF: How to dynamically find a usercontrol or datatemplate
I have a bunch of datatemplates I use to display various sql-views in an ItemsControl. I don't know which datatemplate i'm going to use until run-time. (every view has different columns) Next to that, I made a开发者_运维技巧 generic dynamic datatemplate for all those views that don't need anything special.
When I display the view I want to first look in all the available datatemplates if there is one that matches, else use the default dynamic datatemplate.
My question is how can I 'search' a datatemplate by name in code? Usercontrol is also possible.
Thanks,
Elger
Yep got it:
Use a datatemplateselector or just use window.FindResource to do the trick.
This helped me:
http://www.developingfor.net/net/dynamically-switch-wpf-datatemplate.html
精彩评论