我想實現某種工廠模式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