Windows Phone ApplicationBar BackgroundColor属性样式XamlParseException

我的应用程序中有很多页面,我决定在App.Resources中创建一个全局ApplicationBar样式:

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

但是,当我尝试启动应用程序时,VS给了我一个错误:

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

这不是真的 – ApplicationBar.BackgroundColor Property.有什么问题?

最佳答案 我相信,ApplicationBar属性不能像你尝试的那样使用Binding或样式,因为它不是一个silverlight控件.虽然您可以将整个应用程序栏作为资源.像这样

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

编辑:
或者,如果您希望更改应用程序栏颜色,则可以将其放在资源中.

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

并从代码后面添加按钮.虽然,我没有遇到过这会有所帮助的情况.

点赞