1

I want to change the highlighted color on clicking ListView item in Xamarin Forms - UWP. In android i am setting style to fix this.<item name="android:colorActivatedHighlight">@android:color/transparent</item> How can i achieve the same is UWP. Images added: https://i.sstatic.net/Bgeru.jpg

2 Answers 2

1

Navigate into your UWP project, Open your App.xaml, and place the following:

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.ThemeDictionaries>
        <ResourceDictionary x:Key="Default">

<!--Your accent color-->
<Color x:Key="SystemAccentColor">#FF055ADA</Color>                

<SolidColorBrush x:Key="SystemControlHighlightAltListAccentHighBrush" Color="{ThemeResource SystemAccentColor}" Opacity="0.9" />
<SolidColorBrush x:Key="SystemControlHighlightAltListAccentLowBrush" Color="ThemeResource SystemAccentColor}" Opacity="0.6" />
<SolidColorBrush x:Key="SystemControlHighlightAltListAccentMediumBrush" Color="{ThemeResource SystemAccentColor}" Opacity="0.8" />
<SolidColorBrush x:Key="SystemControlHighlightListAccentHighBrush" Color="{ThemeResource SystemAccentColor}" Opacity="0.9" />
<SolidColorBrush x:Key="SystemControlHighlightListAccentLowBrush" Color="{ThemeResource SystemAccentColor}" Opacity="0.6" />
<SolidColorBrush x:Key="SystemControlHighlightListAccentMediumBrush" Color="{ThemeResource SystemAccentColor}" Opacity="0.8" />

    </ResourceDictionary>
  </ResourceDictionary.ThemeDictionaries>
 </ResourceDictionary>
</Application.Resources>

This should work by overriding the default UWP ResourceDictionary.ThemeDictionaries

Sign up to request clarification or add additional context in comments.

Comments

0

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

Change current resources

Application.Current.Resources["SystemControlHighlightListAccentLowBrush"] = new SolidColorBrush(Colors.Red);
Application.Current.Resources["SystemControlHighlightListAccentMediumBrush"] = new SolidColorBrush(Colors.Red);

or define your own ListViewItemPresenter

4 Comments

Where u use this lines of code ?? in the App.cs of native UWP project ?
Am used it in native UWP MainPage.xaml.cs
Try to use it in App.xaml.cs
It shows error when used in constructor of App. If it is used in Onlauched method no error occurs. But still highlighted color is not changed. Error that is got is System.Exception occurred HResult=0x8000FFFF Message=Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED)) Source=<Cannot evaluate the exception source> when used in contructor

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.