c# - Styling ListView(for custom template) WPF -
i have few questions styling listview. example have style:
<style x:key="mylistview" targettype="{x:type listview}"> <setter property="background" value="{dynamicresource {x:static systemcolors.windowbrushkey}}"/> <setter property="borderbrush" value="{staticresource listborder}"/> <setter property="borderthickness" value="1"/> <setter property="foreground" value="{dynamicresource {x:static systemcolors.controltextbrushkey}}"/> <setter property="scrollviewer.horizontalscrollbarvisibility" value="hidden"/> <setter property="scrollviewer.verticalscrollbarvisibility" value="auto"/> <setter property="scrollviewer.cancontentscroll" value="false"/> <setter property="verticalcontentalignment" value="center"/> <setter property="template"> <setter.value> <controltemplate targettype="{x:type listview}"> <border x:name="part_controlborder" snapstodevicepixels="true" background="{templatebinding background}" borderbrush="{templatebinding borderbrush}" borderthickness="{templatebinding borderthickness}" padding="0"> <grid> <scrollviewer grid.row="1" verticalscrollbarvisibility="hidden" horizontalscrollbarvisibility="hidden" cankeyboardscroll="false" padding="{templatebinding padding}" focusable="false"> <itemspresenter x:name="part_itemspresenter" snapstodevicepixels="{templatebinding snapstodevicepixels}"/> </scrollviewer> </grid> </border> </controltemplate> </setter.value> </setter> <setter property="itemtemplate"> <setter.value> <datatemplate> <border x:name="itemborder" cornerradius="4" snapstodevicepixels="true" borderbrush="{templatebinding borderbrush}" borderthickness="2" padding="1"> <grid> <textblock text="{binding key}" background="lightgray"/> </grid> </border> </datatemplate> </setter.value> </setter> <setter property="itemcontainerstyle"> <setter.value> <style targettype="{x:type listviewitem}"> <setter property="horizontalcontentalignment" value="stretch" /> <style.triggers> <trigger property="isselected" value="true"> <setter property="background" value="{x:null}" /> <setter property="borderbrush" value="{x:null}" /> <setter property="foreground" value="black" /> </trigger> </style.triggers> </style> </setter.value> </setter> </style>
why setters backgroud , borderbrush not working(itemcontainerstyle)? had hide selection using redefinition system brushes, wrong way:
<solidcolorbrush x:key="{x:static systemcolors.highlightbrushkey}" color="#00000000"/>
how set borderbrush itemborder (on mouseover event)?
how set borderbrush itemborder(only selected items)?
what shall change default selection style?
i'd found answer myself. set style itemborder had create few datatriggers , put them datatemplate:
<datatemplate.triggers> <datatrigger binding="{binding relativesource={relativesource mode=findancestor,ancestortype={x:type listviewitem}},path=isselected}" value="true"> <setter targetname="itemborder" property="borderbrush" value="lime"/> </datatrigger> <datatrigger binding="{binding relativesource={relativesource mode=findancestor,ancestortype={x:type listviewitem}}, path=ismouseover}" value="true"> <setter targetname="itemborder" property="borderbrush" value="orange"/> </datatrigger> </datatemplate.triggers>
about question 1 , 4 still haven't answer...(if won't count way change default system brushes)
Comments
Post a Comment