Tarun
Tarun

Reputation: 393

Accessing xaml elements in viewmodel and applying dynamic styles at runtime using wpf mvvm

I need to apply dynamic style to my button in ViewModel on the basis of if else condition. I have created 2 styles for the button in separata user controls using ResourceDictionary with the same Key. This button is in one usercontrol i.e. xaml. How to dynamically apply the styles using style tag and DynamicResource. How to do this with properties?

Kindly Suggest?

Thanks

Upvotes: 1

Views: 686

Answers (1)

MacNET
MacNET

Reputation: 133

By the sounds of things you need to use either MultiTriggers or MultiDataTriggers. You can find out more about MultiTriggers here and MultiDataTriggers here. The triggers allow you to take different actions based on a single or multiple condition(s).

Hope this helps.

Upvotes: 1

Related Questions