Windows Phone ApplicationBar BackgroundColor property style XamlParseException

烈酒焚心 提交于 2019-12-01 20:44:10

问题


I had a lot of pages in my application and I had decided to make a global ApplicationBar style in App.Resources:

<Style TargetType="shell:ApplicationBar">
    <Setter Property="BackgroundColor" Value="#006699" />
</Style>

However, when I tried to start the app, VS gave me an error:

The property 'BackgroundColor' was not found in type 'Microsoft.Phone.Shell.ApplicationBar'.

This isn't true - ApplicationBar.BackgroundColor Property. What's the problem?


回答1:


I believe, ApplicationBar properties cannot use Binding or styling the way you're trying, as it is not a silverlight control. Although you can put the whole applicationbar as a resource. Like so

<shell:ApplicationBar x:Key="MyAppBar" IsVisible="True" BackgroundColor="#006699">
         <shell:ApplicationBarIconButton IconUri="/Images/image.png" Text="image"  IsEnabled="True"/>  
</shell:ApplicationBar>

EDIT: Or you could just put this in the resource if you want your application bar color to change.

<shell:ApplicationBar x:Key="MyAppBar" IsVisible="True" BackgroundColor="#006699">
</shell:ApplicationBar>

And add buttons from code behind. although, I haven't come across a scenario where this would help.



来源:https://stackoverflow.com/questions/8278438/windows-phone-applicationbar-backgroundcolor-property-style-xamlparseexception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!