WPF Custom Control with different styles or templates?
I'm having a WPF Custom Control
which represents me a given point on a plan (I'm making a guide application for my studies) and I want it to looks different for different categories of the objects represented by this map node (i.e. toilet, lift or normal room).
I tried creating a Converter but it didn't goes well. Also my problem is that sometimes in could be the WPF element like Ellipse and sometimes it should be an image开发者_运维问答.
Is it somehow possible to create custom control with multiple templates and the template will be selected depending on some category attribute?
For things like this, you might want to have a look at the DataTemplateSelector class. It allows you to select the datatemplate based on the actual object you are binding to.
Here's a tutorial for it, but i'm sure you can find more on the internet: http://www.switchonthecode.com/tutorials/wpf-tutorial-how-to-use-a-datatemplateselector
精彩评论