xguyor
Topic Author
Posts: 6
Joined: 11 Apr 2024, 19:03

Binding string Dependency Property to datatemplate

27 Oct 2024, 14:11

I have a ResourceDictionary define in a different xaml, in it there are data templates that are then used to be set in a Button ContentTemplate like this:
ContentTemplate="{DynamicResource DataTemplateMicroscope}">
I would like to Bind the DynamicResource name string to a parameter or some private member from the CPP code with a Noesis::DependencyProperty* Button3TypeProperty for example.
I was not able to convert a string such "Microscope" to the actual data template to dynamically determine which datatemplate will be used.
Any suggestions?
 
User avatar
sfernandez
Site Admin
Posts: 3363
Joined: 22 Dec 2011, 19:20

Re: Binding string Dependency Property to datatemplate

28 Oct 2024, 12:25

Hi, you have two options, use a Binding with a Converter that looks for the data template resource based on the input value and converter parameter, or use a DataTemplateSelector (set in the Button ContentTemplateSelector property) in a similar way. This forum topic is talking about exactly that: viewtopic.php?t=3476

Who is online

Users browsing this forum: No registered users and 5 guests