我有以下app.xaml:
<Application>
...
<Application.Resources>
<!-- Application-specific resources -->
<ResourceDictionary>
<viewModels:ViewModelLocator x:Key="ViewModelLocator"></viewModels:ViewModelLocator>
<ResourceDictionary.MergedDictionaries>
<!--
Styles that define common aspects of the platform look and feel
Required by Visual Studio project and item templates
-->
<ResourceDictionary Source="/Styles/Styles.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style x:Key="PivotStylePassStore" TargetType="Pivot">
...
</Style>
</ResourceDictionary>
</Application.Resources>
</Application>
它构建良好,但无法部署 - 存在错误:
xaml重复分配到&#39;项目&#39;的财产 &#39;的ResourceDictionary&#39;对象
删除样式条目时 - 没有问题。发生了什么事?
答案 0 :(得分:2)
将所有自定义/本地样式/资源放在MergedDictionaries
下方。
<Application>
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!--
Styles that define common aspects of the platform look and feel
Required by Visual Studio project and item templates
-->
<ResourceDictionary Source="/Styles/Styles.xaml"/>
</ResourceDictionary.MergedDictionaries>
<!-- Application-specific resources -->
<viewModels:ViewModelLocator x:Key="ViewModelLocator"></viewModels:ViewModelLocator>
<Style x:Key="PivotStylePassStore" TargetType="Pivot">
...
</Style>
</ResourceDictionary>
</Application.Resources>
</Application>
实际上如果它们都高于或低于它们就不会有所作为,但它们必须在一起。 Application.Resources
是Application
的属性,其他所有内容基本上都是Application
XAML元素的“默认”属性(类似Text
TextBoxes
或{ {1}}用于其他各种方式)。你不能将它们混合在一起。