wpf 如何在wpf中添加主题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12914661/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to add a theme in wpf
提问by osunwa
I want to add expressiondark theme on WPF.
我想在 WPF 上添加 expressiondark 主题。
in App.xaml:
在 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:
在 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.
并在项目中添加了 expressiondark.xaml。但是 xpressiondark.xaml 中的所有 xmlns 行都存在错误。
What is wrong?
怎么了?
采纳答案by Fredrik Claesson
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:
查看 ExpressionDark.xaml 的屏幕截图,ResourceDictionary 部分包含许多我的 ExpressionDark.xaml 版本没有的 xmlns 标记,我的版本仅包括:
<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.xamlfile?
你从哪里得到你的ExpressionDark.xaml文件?
Try with this one: http://wpf.codeplex.com/downloads/get/62512
回答by Su Leong
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.
您可以尝试使用 NuGet 安装主题。在 VS 中,转到 Tools>NuGet Package Manager>Package Manager Cnsole 并编写以下命令来安装主题 PM> Install-Package WPF.Themes 这将在您的项目中创建一个名为 Themes 的目录并下载所有主题。它还会将 ResourceDirectory 添加到 yourApp.xaml 中,您可以在其中选择所需的主题。现在您只需要在运行应用程序时拖放工具,您就会看到主题。

