Changing the default colour of selected item in a list view RRS feed

  • Question

  • Hi,

    I am new to metro app development.

    Can somebody tell me what exactly I need to do to change the colour of a list view item when selected.

    The default colour is deep purple but one cannot recognize that it is selected. I want to change it to yellow.

    If possible please describe the steps and share the code for the same.

    Pls look at the attached image. I want the list view item to appear as in the attached image when selected.

    Kindly give me complete code for changing the selected colour to yellow.

    Monday, September 16, 2013 2:20 PM


  • You can find the ListViewItem styles at templates by editing the template in the designer or by looking them up in the ListViewItem styles and templates documentation.

    This will reveal the following dark theme brushes (light theme has the same names, but different values) which can be overridden in App.xaml:

    x:String x:Key="AppName">My App</x:String>
                    <ResourceDictionary x:Key="Default">
                        <SolidColorBrush x:Key="ListViewItemSelectedBackgroundThemeBrush" Color="Yellow" />
                        <SolidColorBrush x:Key="ListViewItemSelectedForegroundThemeBrush" Color="Black" />
                    <ResourceDictionary x:Key="HighContrast">
                        <SolidColorBrush x:Key="ListViewItemSelectedBackgroundThemeBrush" Color="{ThemeResource SystemColorHighlightColor}" />
                        <SolidColorBrush x:Key="ListViewItemSelectedForegroundThemeBrush" Color="{ThemeResource SystemColorHighlightTextColor}" />

    You will want to make sure that you override both the foreground and background to ensure that they match and you don't end up with yellow on white, and that you override in normal modes but still provide appropriate high contrast colors for users who need high contrast mode.


    Tuesday, September 17, 2013 12:45 AM