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

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

سؤال

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