Note that there are some explanatory texts on larger screens.

plurals
  1. POXAML WinRT - Factory Pattern for Custom Styles
    primarykey
    data
    text
    <p>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:</p> <p><img src="https://i.stack.imgur.com/Q70Bg.png" alt="enter image description here"></p> <p><strong>CustomStyles foder</strong> contains the style files. So, based on an enumerator in my <strong>App.xaml.cs</strong> file</p> <pre><code>public enum Style { Style_1, Style_2 } </code></pre> <p>if I choose <strong>Style_1</strong> I'd like to load the xaml file <strong>Style_1.xaml</strong> else <strong>Style_2.xaml</strong> at run-time. Both the style files, have the same definition of Button style, TextBlock style, etc with different property values. Here an example:</p> <p><strong>Style_1.xaml</strong></p> <pre><code>&lt;Style x:Key="Attribute_Label" TargetType="TextBlock"&gt; &lt;Setter Property="FontFamily" Value="Segoe UI" /&gt; &lt;Setter Property="Foreground" Value="#78CAB3" /&gt; &lt;Setter Property="FontSize" Value="15" /&gt; &lt;Setter Property="FontWeight" Value="Normal" /&gt; &lt;/Style&gt; </code></pre> <p><strong>Style_2.xaml</strong></p> <pre><code>&lt;Style x:Key="Attribute_Label" TargetType="TextBlock"&gt; &lt;Setter Property="FontFamily" Value="Arial" /&gt; &lt;Setter Property="Foreground" Value="#606060" /&gt; &lt;Setter Property="FontSize" Value="30" /&gt; &lt;Setter Property="FontWeight" Value="Normal" /&gt; &lt;/Style&gt; </code></pre> <p>There is a way to achieve what I want to do ? Thank you in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload