我想实现某种工厂模式XAML的。我为WinRT创建了一个应用程序,我在其中定义了两个xaml样式文件。基本上,想什么,我实现(如果可能的话)是在应用程序启动时加载两个XAML文件之一。 在Solution Explorer中我有这样的:XAML的WinRT - 工厂模式自定义样式
CustomStyles foder包含样式文件。因此,基于枚举在我App.xaml.cs文件
public enum Style
{
Style_1,
Style_2
}
如果我选择Style_1我想加载XAML文件Style_1.xaml其他Style_2.xaml在运行。 无论是样式文件,有钮扣的款式,TextBlock的风格等不同的属性值相同的定义。 下面一个例子:
Style_1.xaml
<Style x:Key="Attribute_Label" TargetType="TextBlock">
<Setter Property="FontFamily" Value="Segoe UI" />
<Setter Property="Foreground" Value="#78CAB3" />
<Setter Property="FontSize" Value="15" />
<Setter Property="FontWeight" Value="Normal" />
</Style>
Style_2.xaml
<Style x:Key="Attribute_Label" TargetType="TextBlock">
<Setter Property="FontFamily" Value="Arial" />
<Setter Property="Foreground" Value="#606060" />
<Setter Property="FontSize" Value="30" />
<Setter Property="FontWeight" Value="Normal" />
</Style>
有一种方法可以达到我想要做什么?先谢谢你。
好像你正在寻找[主题化(http://stackoverflow.com/questions/11150570/how-to-implement-theming-in-wpf)。不过,我不确定WinRT XAML对此有多大的支持。 –
你还需要奖励吗? :) – pinckerman
如果你想添加更多的声誉,随意:) – davideberdin