XAML WinRT - Factory Pattern for Custom Styles

Viewed 514

I'd like to implement a sort of Factory Pattern for XAML. I created an app for WinRT where I defined two xaml style files. Basically, what I'd like to achieve (if possible) is to load one of the the two xaml file when the application starts. in the solution explorer I have this:

enter image description here

CustomStyles foder contains the style files. So, based on an enumerator in my App.xaml.cs file

public enum Style
{
    Style_1,
    Style_2
}

if I choose Style_1 I'd like to load the xaml file Style_1.xaml else Style_2.xaml at run-time. Both the style files, have the same definition of Button style, TextBlock style, etc with different property values. Here an example:

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>

There is a way to achieve what I want to do ? Thank you in advance.

1 Answers
Related