How to change Highlight color of the selected ListView item in UWP (Windows 10)

后端 未结 4 1725
青春惊慌失措
青春惊慌失措 2020-12-01 15:34

I\'m working on a Windows 10 app using C# and XAML. I have a ListView and I want to change the default HighLight color of an selected item. I was seeing many code examples (

4条回答
  •  青春惊慌失措
    2020-12-01 16:26

    Actually a better way to discover the styling properties is to use Blend.

    First, open up your page in Blend. Then right click on your ListView and go

    Edit Additional Templates > Edit Generated Item Container (ItemContainerStyle) > Edit a Copy.

    Give it a name and hit OK.

    Now, you have generated the full built-in style for your ListViewItems and this is where you can find all the information about their appearance, animations and other visual behaviors.

    You should be look at this piece of code -

    
    

    See the line SelectedBackground="{ThemeResource SystemControlHighlightListAccentLowBrush}"? That's where you can apply your own color to it. Keep in mind that it should be of type Brush instead of Color.

提交回复
热议问题