I am trying to add a resource dictionary to a user control as follows:

User Control View/AllOrdersView.xaml

UserControl

Resource Dictionary View/AllOrdersViewResources.xaml

ResourceDictionary

Solution Explorer Showing the UserControl and ResourceDictionary

SolutionExplorer

Error Message

Cannot add element to property 'Resources', because the property can have only one child element if it uses an explicit collection tag.

Troubleshooting Steps

有帮助吗?

解决方案

Your XAML is wrong. This is the right way to merge ResourceDictionaries:

<UserControl.Resources>
    <ResourceDictionary>
       <ResourceDictionary.MergedDictionaries>
           <ResourceDictionary Source="AllOrdersViewResources.xaml"/>
       </ResourceDictionary.MergedDictionaries>

       <!-- More resources here -->
    </ResourceDictionary>
</UserControl.Resources>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top