views:

71

answers:

1

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

A: 

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][1]

Elger