Question

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

Was it helpful?

Solution

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>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top