Iffy
Iffy

Reputation: 219

WPF Custom Themes

I have a simple question which is giving me some difficulty. I have downloaded a custom them for WPF of the net. Now i want to apply this theme to my App instead of the default one.

How do i do that, Do i do it in XAML or in Code ?

Thanks Iffy

Upvotes: 2

Views: 1278

Answers (2)

Iffy
Iffy

Reputation: 219

I just came across something that answered my problem in one. I used the line

<ResourceDictionary Source="Themes/ExpressionDark.xaml"/>

This i put into my Windows resources inside a merged dictionary. What this did was apply my theme to the window as a default theme. Easy and quick.

Hope this helps others in future.

Thanks Iffy.

Upvotes: 3

bniwredyc
bniwredyc

Reputation: 8839

Add namesapce of your theme:

xmlns:expDark="clr-namespace:System.Windows.Controls.Theming; assembly=System.Windows.Controls.Theming.ExpressionDark"

xmlns:theming="clr-namespace:System.Windows.Controls.Theming;assembly=System.Windows.Controls.Theming.Toolkit"

And wrap your controls with theme in XAML.

<!-- expDark:ExpressionDarkTheme is theme what I want to apply-->
<expDark:ExpressionDarkTheme>
  <Button Content="Счастье" Width="200" Height="50"
  FontSize="26" Margin="10"></Button>
</expDark:ExpressionDarkTheme>

Upvotes: 1

Related Questions