I have a Xamarin project with UWP and need to set background color of Top Command Bar in UWP. I tried adding following in App.xaml in Shared Project (this gives error):
<Style TargetType="CommandBar">
<Setter Property="Background" Value="#F44336" />
</Style>
I also tried adding following in App.xaml in UWP project:
<Application.Resources>
<ResourceDictionary>
<Style TargetType="AppBar">
<Setter Property="Background" Value="#F44336"/>
</Style>
</ResourceDictionary>
</Application.Resources>
Nothing notable change happened. Can anyone please help?
Your second attempt was completely correct
<Application.Resources>
<ResourceDictionary>
<Style TargetType="AppBar">
<Setter Property="Background" Value="#F44336"/>
</Style>
</ResourceDictionary>
</Application.Resources>
However, you simply were targeting AppBar instead of CommandBar :) Try this:
<Application.Resources>
<ResourceDictionary>
<Style TargetType="CommandBar">
<Setter Property="Background" Value="#F44336"/>
</Style>
</ResourceDictionary>
</Application.Resources>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.