c# - Change the background color when listbox is disabled -


i have listbox, , want change background color when listbox disabled , style variable "negative" or "positive", initial, did below:

//----------------------------updated----------------------------

<listbox>     <listbox.style>         <style targettype="{x:type listbox}">             <style.triggers>                 <multidatatrigger>                     <multidatatrigger.conditions>                         <condition binding="{binding relativesource={relativesource self}, path=isenable}" value="false"/>                         <condition binding="{binding path=style}" value="negative"/>                     </multidatatrigger.conditions>                     <setter property="background" value="black" />                 </multidatatrigger>                 <multidatatrigger>                     <multidatatrigger.conditions>                         <condition binding="{binding relativesource={relativesource self}, path=isenable}" value="false"/>                         <condition binding="{binding path=style}" value="positive"/>                     </multidatatrigger.conditions>                     <setter property="background" value="yellow" />                 </multidatatrigger>             </style.triggers>         </style>     </listbox.style> </listbox> 

but, not worked, listbox can't change background color above solution, did below: //----------------------------end updated----------------------------

<stackpanel>     <listbox isenabled="{binding elementname=enabledbutton, path=ischecked}">         <listbox.resources>             <solidcolorbrush x:key="{x:static systemcolors.controlbrushkey}" color="red" />         </listbox.resources>         <listboxitem>item 1</listboxitem>         <listboxitem>item 2</listboxitem>         <listboxitem>item 3</listboxitem>         <listboxitem>item 4</listboxitem>         <listboxitem>item 5</listboxitem>     </listbox>     <togglebutton name="enabledbutton" ischecked="true" content="isenabled"/> </stackpanel> 

it's work! listbox can change background color red when disabled.

but, need add condition:

-if style negative (style="negative"), listbox change color "black".

-if style positive (style="positive"), listbox change color "yellow".

i tried use trigger, unsuccessful. have simple way working?


Comments

Popular posts from this blog

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -