我最初在MVVM Light CodePlex页面上发布了这条信息,但还没有收到回复,所以我希望这里的某个人能帮助我。以下是问题:
我最近开始尝试使用MVVM(也是WPF的新手-对于所有这些内容来说,学习曲线相当陡峭),我的ViewModelLocator实例和绑定设计时间与VS2010一起工作得很好,直到我开始使用CodePlex上提供的MetroToolkit之前。在利用工具包之前,我有以下内容:
我最近开始尝试使用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>
我尝试为资源字典添加一个键,将该行代码放在<Application.Resources>
区域之外(上方和下方 - 会抛出令人讨厌且无用的错误),但无法找到我的VM Locator。如果我从App.xaml中删除<ResourceDictionary>
块,它会立即起作用,但基于我对WPF的非常有限的了解,如果我希望样式对应用程序中的所有视图都可用,就需要这些。
有什么想法吗?这让我疯狂了几个小时。