Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

How to prevent changed color of listview selected item not to affect listview context menu

$
0
0

In a list view I was able to prevent the background color on a selected item from showing, see xaml below.  But on the listview context menu I what the selected item to be highlighted.  So how do I get the default back for context menu brushes (see SystemColors.???? in xaml)  ?  Or is there a way to prevent what I set for the listview to affect it's context menu?

 <ListView x:Uid="Grid_1" Name="List1" AutomationProperties.AutomationId="Listview1">
        <ListView.Resources>
            <!--background of selected item when focused -->
            <SolidColorBrush x:Uid="brush1" x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="{DynamicResource {x:Static SystemColors.WindowColorKey}}" />
            <!-- background of selected item when NOT focused -->
            <SolidColorBrush x:Uid="brush2" x:Key="{x:Static SystemColors.ControlBrushKey}" Color="{DynamicResource {x:Static SystemColors.WindowColorKey}}" /> 
        </ListView.Resources> 
       
 <ListView.ContextMenu>
            <ContextMenu x:Uid="contextMenu" Name="contextMenu"  AutomationProperties.AutomationId="overlayContextMenu"  >
               
  <ContextMenu.Resources>
                    <SolidColorBrush x:Uid="brush1" x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="{DynamicResource {x:Static SystemColors.????}}" />
                    <SolidColorBrush x:Uid="brush2" x:Key="{x:Static SystemColors.ControlBrushKey}" Color="{DynamicResource {x:Static SystemColors.????}}" />
                </ContextMenu.Resources>

                <ContextMenu.Items>
                    <MenuItem x:Uid="MenuItem_1a" Command="{Binding Path=Command1, Mode=OneWay}" Header="{Binding Path=DisplayName1, Mode=OneWay}" />
                    <MenuItem x:Uid="MenuItem_1b" Command="{Binding Path=Command2, Mode=OneWay}" Header="{Binding Path=DisplayName2, Mode=OneWay}"  />
                </ContextMenu.Items>
            </ContextMenu>
        </ListView.ContextMenu>


Elizzabeth Zelasky


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>