Wanderer
Topic Author
Posts: 168
Joined: 08 May 2017, 18:36

Button and action for change the "style" (how to?)

11 Mar 2018, 10:45

I have basic button and I want change the button style after something happen. For example, if Label or any element get value 1, button change color scheme, and if value from element get back to 0, button get previous color scheme.
Idea to change color scheme is duplicated graphic but with diferent colors. And when value is 0, duplicated graphics are hidden, and when value is 1, then graphics will be hidden and duplicated visible.
Idea is bind visibility to the value, but button don't have value, and I have no idea how or where to bind it.
How to do this without codebehind? It is possible?
 
User avatar
sfernandez
Site Admin
Posts: 1938
Joined: 22 Dec 2011, 19:20

Re: Button and action for change the "style" (how to?)

12 Mar 2018, 17:28

You can for example bind Button.Tag property to the element that is receiving these values of 0/1.
Then you can use that from inside Button's ControlTemplate to enable the corresponding color scheme.

Would that work for you?
 
Wanderer
Topic Author
Posts: 168
Joined: 08 May 2017, 18:36

Re: Button and action for change the "style" (how to?)

12 Mar 2018, 18:51

Can you provide some example please? It is not necessary because at last I decide to use code behind (because I discover that I need more then 2 states, and values will be computed in codebehind), but for future examples it will be helpful. I bind visibility to the
<Canvas ... Visibility="{Binding visual_ok_visibility}">
<Canvas ... Visibility="{Binding visual_error_visibility}">
//...
This is inside button template. It will be working with Codebehind? This button is in UserControl.

Who is online

Users browsing this forum: No registered users and 4 guests