Windows phone 8 Caliburn Micro资源字典 app.xaml
样式/Styles.xaml中的我的资源Windows phone 8 Caliburn Micro资源字典 app.xaml,windows-phone-8,caliburn.micro,Windows Phone 8,Caliburn.micro,样式/Styles.xaml中的我的资源 app.xaml <Application.Resources> <local:AppBootstrapper xmlns:local="clr-namespace:Kyms" x:Key="Bootstrapper" /> <local:LocalizedStrings xmlns:local="clr-namespace:Kyms" x:Key="LocalizedStrings"/> &
app.xaml
<Application.Resources>
<local:AppBootstrapper xmlns:local="clr-namespace:Kyms" x:Key="Bootstrapper" />
<local:LocalizedStrings xmlns:local="clr-namespace:Kyms" x:Key="LocalizedStrings"/>
<ResourceDictionary x:Key="CustomDictionary">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Styles/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
.......
在ViewModel中(使用caliburn micro MVVM模式),如果我调用此代码
App.Current.Resources.MergedDictionaries[0]
App.Current.Resources.MergedDictionaries.Count=0
但它不起作用,为什么?我下定决心了
在我的AppBootstrapper.cs中,我是insert
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">
<Style x:Key="MyColorButton" TargetType="Button">
.......
</Style>
而且它有效
private void LoadDictionary()
{
var dictionaries = App.Current.Resources.MergedDictionaries;
dictionaries.Clear();
var themeStyles = new ResourceDictionary { Source = new Uri("/MyAssemblyName;component/Styles/Styles.xaml", UriKind.RelativeOrAbsolute) };
dictionaries.Add(themeStyles);
}