vb.net - WPF ListView Style Borders -


today started teaching self how create wpf application (finally)

so starting used have hit bit of snag styling listview.

in top picture can see working (no border around selection)

enter image description here

however in second picture can see small border around selection.. seems happens when use keyboard go next item in list.

is there missing in styles can rid of border?

code: (remember started learning today messy)

listview styles

<style targettype="{x:type listview}">     <setter property="borderthickness" value="0" />     <style.triggers>         <trigger property="ismouseover" value="true">             <setter property="borderthickness" value="0" />         </trigger>         <trigger property="isselected" value="true">             <setter property="borderthickness" value="0" />         </trigger>     </style.triggers> </style>  <style targettype="{x:type listviewitem}">     <setter property="borderthickness" value="0" />     <setter property="foreground" value="#4b0037" />      <setter property="template">         <setter.value>             <controltemplate targettype="{x:type listviewitem}">                 <border                      borderbrush="transparent"                      borderthickness="0"                      background="{templatebinding background}">                     <gridviewrowpresenter horizontalalignment="stretch" verticalalignment="{templatebinding verticalcontentalignment}" width="auto" margin="0" content="{templatebinding content}"/>                 </border>             </controltemplate>         </setter.value>     </setter>      <style.triggers>         <trigger property="ismouseover" value="true">             <setter property="background">                 <setter.value>                     <imagebrush imagesource="images/selection.png"/>                 </setter.value>             </setter>             <setter property="borderthickness" value="0" />         </trigger>         <trigger property="isselected" value="true">             <setter property="background">                 <setter.value>                     <imagebrush imagesource="images/selection.png"/>                 </setter.value>             </setter>             <setter property="borderthickness" value="0" />             <setter property="foreground" value="#ffffff" />         </trigger>     </style.triggers> </style> 

listview xaml

            <listview background="transparent" margin="10 10 10 10" x:name="mylist" horizontalalignment="stretch" verticalcontentalignment="center" verticalalignment="stretch" borderbrush="transparent">             <listview.view>                 <gridview>                     <gridviewcolumn header="img" width="150" displaymemberbinding="{binding img}" />                     <gridviewcolumn header="name" width="150" displaymemberbinding="{binding name}" />                     <gridviewcolumn header="path" width="150" displaymemberbinding="{binding path}" />                 </gridview>             </listview.view>         </listview> 

sorry, easier if had grid view working somewhere.
second idea this: listviewitems have focusvisualstyle. can set in style:

<setter property="listviewitem.focusvisualstyle" value="{dynamicresource listviewitemfocusvisualstyle}" /> 

(or set null done here: wpf listview in gridview mode highlighting problem)

the style this:

<style.resources>     <style x:key="listviewitemfocusvisualstyle">         <setter property="control.template">             <setter.value>                 <controltemplate>                     <rectangle margin="4, 1" strokethickness="1"                                stroke="{dynamicresource {x:static systemcolors.controltextbrushkey}}"                                strokedasharray="1 2"                                snapstodevicepixels="true" />                 </controltemplate>             </setter.value>         </setter>     </style> </style.resources> 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -