Button and action for change the "style" (how to?)
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?
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?
-
sfernandez
Site Admin
- Posts: 2991
- Joined:
Re: Button and action for change the "style" (how to?)
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?
Then you can use that from inside Button's ControlTemplate to enable the corresponding color scheme.
Would that work for you?
Re: Button and action for change the "style" (how to?)
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
This is inside button template. It will be working with Codebehind? This button is in UserControl.
Code: Select all
<Canvas ... Visibility="{Binding visual_ok_visibility}">
<Canvas ... Visibility="{Binding visual_error_visibility}">
//...
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 11 guests