Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I got this to work. My specific goal was to load a ResourceDictionary into the App class so I could have custom skins loaded from raw XAML files. Here's how. First, in App.xaml, Add the following:</p> <pre><code> protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); LoadSkin("Skins/Skin1.xaml"); } private void LoadSkin(string FilePath) { XmlReader XmlRead = XmlReader.Create(FilePath); Application.Current.Resources = (ResourceDictionary)XamlReader.Load(XmlRead); XmlRead.Close(); } </code></pre> <p>Create a "bin\Debug\Skins" folder and added a "Skin1.xaml" with the following content:</p> <pre><code>&lt;ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" &gt; &lt;Style x:Key="ButtonAStyle" TargetType="{x:Type Button}"&gt; &lt;Setter Property="Control.Background" Value="Green" /&gt; &lt;Setter Property="Control.Foreground" Value="White" /&gt; &lt;/Style&gt; &lt;/ResourceDictionary&gt; </code></pre> <hr> <p><strong>Specific to Skins</strong></p> <p>In this particular case, you have to make sure you are using the style resources correctly in your individual windows. Here's an example:</p> <pre><code>&lt;Button Name="button1" Style="{DynamicResource ButtonAStyle}" Click="button1_Click" &gt;Button&lt;/Button&gt; </code></pre> <p>Here's a neat trick to try. In button1_Click(), try adding the same code you did in App.OnStartUp() above but with "Skin2.xaml" with "Red" as the background color for your buttons. The skin changes instantly without requiring a reload of the app or window.</p>
    singulars
    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.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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