I have following 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>
It builds fine, but cannot it deploy - there is error:
xaml Duplication assignment to the 'Items' property of the 'ResourceDictionary' object
When style entry is removed - there is no problem. What is going on?
Place all your custom/local styles/resources below the 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>
Actually it shouldn't make a difference if they are all above or below, but they have to be together. Application.Resources
is a property of Application
, everything else is basically the "default" property of the Application
XAML Element (kind of like Text
for TextBoxes
or Content
for various others). You can't mix them together.
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.