osunwa
osunwa

Reputation: 49

How to add a theme in wpf

error I want to add expressiondark theme on WPF.

in App.xaml:

<Application x:Class="ThemesSample.App" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    StartupUri="MYWINDOW.xaml"> 
    <Application.Resources> 
        <ResourceDictionary Source="ExpressionDark.xaml"/> 
    </Application.Resources> 
</Application> 

in MainWindow.cs:

public MainWindow()
{ 
    ResourceDictionary skin = new ResourceDictionary(); 
    skin.Source = new Uri(@"MYPROJECTADDR\ExpressionDark.xaml", UriKind.Absolute); 
    App.Current.Resources.MergedDictionaries.Add(skin); 
}

and added expressiondark.xaml in project. But there are errors all xmlns lines in xpressiondark.xaml.

What is wrong?

Upvotes: 3

Views: 14484

Answers (2)

Su Leong
Su Leong

Reputation: 66

You can try using NuGet to install theme. From VS, go to Tools>NuGet Package Manager>Package Manager Cnsole and write the following command to install theme PM> Install-Package WPF.Themes this will make a directory in your project called Themes and download all the themes. it will also add ResourceDirectory to yourApp.xaml where you can select the desired theme. Now you just need to drag and drop the tools when you run your app you will see the theme.

Upvotes: 2

Fredrik Claesson
Fredrik Claesson

Reputation: 629

Looking at the ScreenShot of your ExpressionDark.xaml the ResourceDictionary section contains alot of xmlns tags that my version of ExpressionDark.xaml does not have, my version only includes:

<ResourceDictionary
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  mc:Ignorable="d"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008">

Where did you get your ExpressionDark.xaml file?

Try with this one: http://wpf.codeplex.com/downloads/get/62512

Upvotes: 3

Related Questions