xaml - ListBox selected item background color -


trying make tab control out of listbox. if listboxitems text, it's easy see tab selected, add image/path content of listboxitem, no longer shows being selected when clicked. item below shows when selected "hello world" item. want background of tab change color when selected.

<listbox>  <listbox.itemspanel>             <itemspaneltemplate>                 <stackpanel orientation="horizontal" />             </itemspaneltemplate>         </listbox.itemspanel>         <listboxitem>             <canvas width="53.3333" height="53.3333">                 <path width="4.22434" height="4.224" stretch="fill" fill="#ff000000" data="..."/>                            </canvas>         </listboxitem>         <listboxitem>             <listboxitem.content>                 <canvas width="46.6667" height="45.3333">                     <path width="46.3232" height="43.9357"                            canvas.left="0.51729"                            canvas.top="1.06295"                            stretch="fill"                            fill="#ff000000"                            data="..."                 </canvas>             </listboxitem.content>         </listboxitem>         <listboxitem content="hello world">         </listboxitem>     </listbox> 

i did 1 of apps using listview. should similar listbox might want use listview similar , know works. need modify style set selectedbackground , selectedpointeroverbackground colors. set them blue in style below.

        <style x:key="listviewitemtabstyle" targettype="listviewitem">             <setter property="fontfamily" value="{themeresource contentcontrolthemefontfamily}" />             <setter property="fontsize" value="30" />             <setter property="background" value="transparent"/>             <setter property="tabnavigation" value="local"/>             <setter property="isholdingenabled" value="true"/>             <setter property="margin" value="0,0,0,0"/>             <setter property="horizontalcontentalignment" value="left"/>             <setter property="verticalcontentalignment" value="center"/>             <setter property="template">                 <setter.value>                     <controltemplate targettype="listviewitem">                     <listviewitempresenter                     contenttransitions="{templatebinding contenttransitions}"                     padding="{templatebinding padding}"                     selectioncheckmarkvisualenabled="false"                     checkhintbrush="{themeresource listviewitemcheckhintthemebrush}"                     checkselectingbrush="{themeresource listviewitemcheckselectingthemebrush}"                     checkbrush="{themeresource listviewitemcheckthemebrush}"                     dragbackground="{themeresource listviewitemdragbackgroundthemebrush}"                     dragforeground="{themeresource listviewitemdragforegroundthemebrush}"                     focusborderbrush="{themeresource listviewitemfocusborderthemebrush}"                     placeholderbackground="{themeresource listviewitemplaceholderbackgroundthemebrush}"                     pointeroverbackground="{themeresource listviewitempointeroverbackgroundthemebrush}"                     selectedborderthickness="{themeresource listviewitemcompactselectedborderthemethickness}"                     selectedbackground="blue"                     selectedforeground="{themeresource listviewitemselectedforegroundthemebrush}"                     selectedpointeroverbackground="blue"                     selectedpointeroverborderbrush="{themeresource listviewitemselectedpointeroverborderthemebrush}"                     disabledopacity="{themeresource listviewitemdisabledthemeopacity}"                     dragopacity="{themeresource listviewitemdragthemeopacity}"                     reorderhintoffset="{themeresource listviewitemreorderhintthemeoffset}"                     horizontalcontentalignment="{templatebinding horizontalcontentalignment}"                     verticalcontentalignment="{templatebinding verticalcontentalignment}"                     pointeroverbackgroundmargin="1"                     contentmargin="4" />                     </controltemplate>                 </setter.value>             </setter>         </style> 

and set style listview this:

<listview itemcontainerstyle="{staticresource resourcekey=listviewitemtabstyle}"  background="gray" selectedindex="0">      <listviewitem content="item1"/>      <listviewitem content="item2"/>      <listviewitem content="item3"/> </listview> 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -