c# - WPF Listview - only highlight part of a ListViewItem -
i'm trying create listview image , textblocks want textblock section show highlights when listviewitem gets focus.
i think need set focusable=false , override mouseover highlight style, , implement own highlighting, don't know if it's right approach , what's best way it.
here current xaml:
<window x:class="wpfapplication1.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:wpfapplication1" mc:ignorable="d" title="mainwindow" height="509.468" width="1006.164" loaded="window_loaded"> <window.resources> <local:clonemarginconverter x:key="clonemarginconverter" /> <datatemplate x:key="selectedtemplate" datatype="{x:type local:mainwindow}"> <wrappanel margin="{binding cloneof, converter={staticresource clonemarginconverter}}"> <canvas> <image name="icon" source="{binding icon}" width="32" height="32" margin="0,0,5,0" cliptobounds="false" /> </canvas> <textblock text="{binding description}" margin="37,0,5,0"/> <textblock text="{binding year}" /> </wrappanel> </datatemplate> <datatemplate x:key="unselectedtemplate" datatype="{x:type local:mainwindow}"> <wrappanel margin="{binding cloneof, converter={staticresource clonemarginconverter}}"> <image name="icon" source="{binding icon}" width="16" height="16" margin="16,0,5,0" /> <textblock text="{binding description}" margin="0,0,5,0" /> <textblock text="{binding year}" /> </wrappanel> </datatemplate> </window.resources> <grid background="green"> <listview x:name="listview" margin="10" selectionchanged="listview_selectionchanged" background="transparent" borderthickness="0"> <listview.itemcontainerstyle> <style targettype="listviewitem"> <setter property="horizontalalignment" value="left" /> <setter property="contenttemplate" value="{staticresource unselectedtemplate}" /> <setter property="panel.zindex" value="9"/> <style.triggers> <trigger property="isselected" value="true"> <setter property="contenttemplate" value="{staticresource selectedtemplate}" /> <setter property="panel.zindex" value="10"/> </trigger> </style.triggers> </style> </listview.itemcontainerstyle> </listview> </grid>
Comments
Post a Comment