MVVM Light ViewModelLocator + ResourceDictionaries

|| 我最初将此消息发布在MVVM Light CodePlex页面上,但尚未收到回复,因此我希望这里的人能够为我提供帮助。这是问题: 我最近开始使用MVVM(也是WPF的新手-相当多的学习曲线),在我使用ViewModelLocator实例和VS2010的绑定设计时,一切都运转良好,直到我开始使用CodePlex上提供的MetroToolkit。在使用该工具包之前,我有以下几点:
<Application.Resources>
    <local:ViewModelLocator x:Key=\"Locator\" d:IsDataSource=\"True\" />
</Application.Resources>
我所有的观点都具有约束力,一切看起来都很好。没有MVVM(或MVC)经验的人可以轻松地启动并运行,我感到惊讶。然后我碰到了MetroToolkit的麻烦,需要合并资源字典,现在无论如何我都无法让VS在App.xaml中再次找到ViewModelLocator。这是新的标记:
<Application.Resources>

        <ResourceDictionary>

            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source=\"/MetroToolkit;component/Themes/Dark/Colors.xaml\" />
                <ResourceDictionary Source=\"/MetroToolkit;component/Themes/Dark/Animations.xaml\" />
                <ResourceDictionary Source=\"/MetroToolkit;component/Themes/Dark/Geometry.xaml\"/>
                <ResourceDictionary Source=\"/MetroToolkit;component/Themes/Dark/Generic.xaml\"/>
                <ResourceDictionary Source=\"/MetroToolkit;component/Themes/Dark/Buttons.xaml\" />
                <ResourceDictionary Source=\"/MetroToolkit;component/Themes/Dark/Scrollbar.xaml\" />
                <ResourceDictionary Source=\"/MetroToolkit;component/Themes/Dark/Scrollviewer.xaml\" />
                <ResourceDictionary Source=\"/MetroToolkit;component/Themes/Dark/RadioButton.xaml\" />
                <ResourceDictionary Source=\"/MetroToolkit;component/Themes/Dark/ProgressBar.xaml\" />
                <ResourceDictionary Source=\"/MetroToolkit;component/Themes/Dark/ContextMenu.xaml\" />
                <ResourceDictionary Source=\"/MetroToolkit;component/Themes/Dark/Tooltip.xaml\" />
                <ResourceDictionary Source=\"/MetroToolkit;component/Themes/Dark/Checkbox.xaml\" />
                <ResourceDictionary Source=\"/MetroToolkit;component/Themes/Dark/Headings.xaml\" />
                <ResourceDictionary Source=\"/MetroToolkit;component/Themes/Dark/Textbox.xaml\" />
                <ResourceDictionary Source=\"/MetroToolkit;component/Themes/Dark/Combobox.xaml\" />
                <ResourceDictionary Source=\"/MetroToolkit;component/Themes/Dark/Slider.xaml\" />
                <ResourceDictionary Source=\"/MetroToolkit;component/Themes/Dark/Expander.xaml\" />
                <ResourceDictionary Source=\"/MetroToolkit;component/Themes/Dark/TabControl.xaml\" />
            </ResourceDictionary.MergedDictionaries>

            <local:ViewModelLocator x:Key=\"Locator\" d:IsDataSource=\"True\" />

        </ResourceDictionary>
    </Application.Resources>    
我试着给资源字典一个键,在区域之外添加行(上方和下方-抛出令人讨厌且非常无益的错误),但找不到它来找到我的VM定位器。当我从App.xaml中删除该块时,它可以立即工作,但是基于我对WPF的非常有限的了解,如果我希望样式可用于我的应用程序中的所有视图,则需要那些。 有什么想法吗?这已经使我疯狂了几个小时。     
已邀请:
        是的...前几天我刚看到这...您必须在其中放入资源字典...
    <ResourceDictionary>

                <ResourceDictionary.MergedDictionaries>
                    <ResourceDictionary Source=\"/MetroToolkit;component/Themes/Dark/Colors.xaml\" />
                    <ResourceDictionary Source=\"/MetroToolkit;component/Themes/Dark/Animations.xaml\" />
                    <ResourceDictionary Source=\"/MetroToolkit;component/Themes/Dark/Geometry.xaml\"/>
                    <ResourceDictionary Source=\"/MetroToolkit;component/Themes/Dark/Generic.xaml\"/>
                    <ResourceDictionary Source=\"/MetroToolkit;component/Themes/Dark/Buttons.xaml\" />
                    <ResourceDictionary Source=\"/MetroToolkit;component/Themes/Dark/Scrollbar.xaml\" />
                    <ResourceDictionary Source=\"/MetroToolkit;component/Themes/Dark/Scrollviewer.xaml\" />
                    <ResourceDictionary Source=\"/MetroToolkit;component/Themes/Dark/RadioButton.xaml\" />
                    <ResourceDictionary Source=\"/MetroToolkit;component/Themes/Dark/ProgressBar.xaml\" />
                    <ResourceDictionary Source=\"/MetroToolkit;component/Themes/Dark/ContextMenu.xaml\" />
                    <ResourceDictionary Source=\"/MetroToolkit;component/Themes/Dark/Tooltip.xaml\" />
                    <ResourceDictionary Source=\"/MetroToolkit;component/Themes/Dark/Checkbox.xaml\" />
                    <ResourceDictionary Source=\"/MetroToolkit;component/Themes/Dark/Headings.xaml\" />
                    <ResourceDictionary Source=\"/MetroToolkit;component/Themes/Dark/Textbox.xaml\" />
                    <ResourceDictionary Source=\"/MetroToolkit;component/Themes/Dark/Combobox.xaml\" />
                    <ResourceDictionary Source=\"/MetroToolkit;component/Themes/Dark/Slider.xaml\" />
                    <ResourceDictionary Source=\"/MetroToolkit;component/Themes/Dark/Expander.xaml\" />
                    <ResourceDictionary Source=\"/MetroToolkit;component/Themes/Dark/TabControl.xaml\" />
 <ResourceDictionary>
                     <local:ViewModelLocator x:Key=\"Locator\" d:IsDataSource=\"True\" />
                </ResourceDictionary>
                </ResourceDictionary.MergedDictionaries>

        </ResourceDictionary>
**编辑 抱歉...现在解决了...我要从内存中删除...这就是我的想法。
<ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source=\"Dictionaries/converters.xaml\" />
                <ResourceDictionary Source=\"assets/styles.xaml\" />
                <ResourceDictionary Source=\"assets/sdkstyles.xaml\" />
                <ResourceDictionary Source=\"assets/corestyles.xaml\" />
                <ResourceDictionary>
                    <local:ApplicationResources x:Key=\"ApplicationResources\" />
                </ResourceDictionary>

            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    

要回复问题请先登录注册