我最初在MVVM Light CodePlex页面上发布了这条消息,但还没有收到回复,所以我希望这里有人能帮助我。问题是:
我最近开始玩MVVM(也是WPF的新手,这是所有这些的学习曲线),在我开始使用CodePlex上提供的MetroToolkit之前,我的ViewModelLocator实例和VS2010的绑定设计时一切都很好。在使用工具包之前,我有以下内容:
<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的有限了解,如果我想让样式对应用程序中的所有视图都可用,我需要这些样式。
有什么想法吗?这已经让我发疯好几个小时了。