c# - Disable Control's Selection Background Effect in WPF -


i have listview shows collection of objects. want disable "blue effect" or "blue rectangle" when clicking on listviewitem, , let object in item enabled. has idea ??

here example of 1 of listviewitems:

lisviewitem

here listview:

<listview selectionmode="single" ismanipulationenabled="true" horizontalalignment="left" horizontalcontentalignment="stretch" verticalalignment="stretch" scrollviewer.verticalscrollbarvisibility="auto" itemssource="{binding childrenlist}" background="transparent" borderbrush="transparent" >         <listview.layouttransform>             <rotatetransform angle="{binding isvertical, converter={staticresource angleofbool}}"></rotatetransform>         </listview.layouttransform>         <listview.itemtemplate>             <datatemplate>                 <grid horizontalalignment="stretch" background="transparent" >                     <grid.columndefinitions>                         <columndefinition width="auto"></columndefinition>                         <columndefinition></columndefinition>                     </grid.columndefinitions>                     <checkbox   content="{binding id}"  height="auto" name="flag" horizontalalignment="left" verticalalignment="top" grid.column="0" ischecked="{binding isvisible}"/>                     <grid grid.column="1">                         <area:area horizontalalignment="stretch" visibility="{binding isvisible, converter={staticresource visibilityofbool}}" />                     </grid>                 </grid>             </datatemplate>         </listview.itemtemplate> </listview> 

setting isenabled property of parent control false automatically set isenabled property of every child control false well. way around set isenabled property of individual controls want disabled false, instead of of parent control.

however, can create 1 bool property bind isenabled property of of relevant controls @ least, can disable , enable them using 1 property:

<grid name="parent">     <grid.columndefinitions>         <columndefinition width="auto"></columndefinition>         <columndefinition width="auto"></columndefinition>     </grid.columndefinitions>     <contentcontrol isenabled="areinnercontrolsenabled" grid.column="0" content="{binding}" visibility="{binding isvisible, converter= {staticresource visibilityofbool} }"></contentcontrol>     <grid grid.column="1" visibility="{binding isvisible, converter= {staticresource visibilityofbool} }" horizontalalignment="stretch">         <grid.rowdefinitions>             <rowdefinition height="0.5*"></rowdefinition>             <rowdefinition height="0.5*"></rowdefinition>         </grid.rowdefinitions>         <label isenabled="areinnercontrolsenabled" grid.row="0" background="transparent" content="{binding top}" verticalalignment="top" horizontalalignment="stretch"></label>         <label grid.row="1" background="transparent" content="{binding bottom}" verticalalignment="bottom" horizontalalignment="stretch"></label>     </grid> </grid> 

using method, controls using areinnercontrolsenabled property affected.

update >>>

so turns out want remove default selection colour of listview... different 'appeared' asking. however, know that, can achieve using simple style:

<style x:key="hiddendefaultselectionstyle" targettype="{x:type listviewitem     <style.resources>         <solidcolorbrush x:key="{x:static systemcolors.highlightbrushkey}" color="transparent" />         <solidcolorbrush x:key="{x:static systemcolors.controlbrushkey}" color="transparent         <solidcolorbrush x:key="{x:static systemcolors.highlighttextbrushkey}" color="black" />         <solidcolorbrush x:key="{x:static systemcolors.controltextbrushkey}" color="black" />     </style.resources> </style> 

you need 1 of these hide colour, have shown rest future reference. can use this:

<listview itemcontainerstyle="{staticresource hiddendefaultselectionstyle}" ... /> 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -