WPF user control with different styles or patterns?

I have a WPF Custom Control that presents me with a certain point in the plan (I create a landmark application for my research) and I want it to look different for the different categories of objects represented by this node map (i.e. toilet elevator or ordinary room).
Can someone give me some idea on how to do this?

I tried to create a converter, but that didn't work. Also my problem is that sometimes it can be a WPF element like Ellipse and sometimes it has to be an image.

Is it possible to create a user control with several templates, and the template will be selected depending on the attribute of any category?

+6
source share
1 answer

For such things, you may need to familiarize yourself with the DataTemplateSelector class. It allows you to select a data template based on the actual object to which you are attached.

Here is a tutorial for this, but I'm sure you can find more on the Internet: http://www.switchonthecode.com/tutorials/wpf-tutorial-how-to-use-a-datatemplateselector

+4
source

Source: https://habr.com/ru/post/888396/


All Articles