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
Add a comment
|
2 Answers
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
Comments
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
puko
Where u use this lines of code ?? in the App.cs of native UWP project ?
Renjith
Am used it in native UWP MainPage.xaml.cs
puko
Try to use it in App.xaml.cs
Renjith
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