WPF Resources - the property can have only one child element if it uses an explicit collection tag

StackOverflow https://stackoverflow.com/questions/23115624

Pergunta

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

Foi útil?

Solução

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>
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top