c# 4.0 - wpf Treeview CheckBox Item ForeGround Color cannot Change when it is disabled? -
this xaml style treeview checkbox item. i'm using syncfusion treeview.
<style x:key="contractlistitemcontainerstyle" targettype="{x:type syncfusion:treeviewitemadv}"> <setter property="isexpanded" value="true" /> <setter property="isselected" value="{binding isinitiallyselected, mode=onetime}" /> <setter property="keyboardnavigation.acceptsreturn" value="true" /> <setter property="iseditable" value="false" /> <setter property="isenabled" value="{binding enable}" /> <setter property="foreground" value="red" /> <style.triggers> <trigger property="isenabled" value="true"> <setter property="foreground" value="green" /> </trigger> <trigger property="isenabled" value="false"> <setter property="foreground" value="red" /> </trigger> </style.triggers> </style> <hierarchicaldatatemplate x:key="selectedcontractsdatatemplate" itemssource="{binding children}" > <stackpanel orientation="horizontal"> <checkbox margin="2,0,2,0" focusable="false" ischecked="{binding content.ischecked}" verticalalignment="center" /> <contentpresenter content="{binding}" margin="2,0" /> </stackpanel> </hierarchicaldatatemplate>
if set enable false viewmodel, color doesn't change red if set true, changes green. why? pelase advise.
the code should work, see/try this:
<stackpanel> <checkbox name="chk" content="check this..."> <checkbox.style> <style> <setter property="checkbox.foreground" value="red" /> <style.triggers> <trigger property="checkbox.isenabled" value="true"> <setter property="checkbox.foreground" value="green" /> </trigger> <trigger property="checkbox.isenabled" value="false"> <setter property="checkbox.foreground" value="red" /> </trigger> </style.triggers> </style> </checkbox.style> </checkbox> <button content="press" click="button_click"/> </stackpanel>
probably wrong binding?
Comments
Post a Comment