image - WPF DataGrid changing a button text depending on a value -


i have text on button changed when value of variable changing. example: value of var 0 (turned off), button should display text "turn on"; if var value 1 button should display "turn off". display image in column depending on value of variable. how can it?

if you're using mvvm, can add property on viewmodel returns either "turn on" or "turn off", implement inotifypropertychanged tell binding system when value changes, , bind button's content it:

<button content="{binding buttontext}"/> 

if you're not using mvvm, you'll need write value converter. you'll still need backing object implement inotifypropertychanged -- otherwise button never know boolean value changed, never update text. recommend viewmodel approach instead of value converter.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -