资源简介
WPF样式大全,20多套不同风格的样式,包含tabcontrol、datagrid、button、combobox、menu、Progressbar、expander、textbox等常用的控件样式。
代码片段和文件信息
namespace WPF.Themes
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows;
using System.Windows.Controls;
public static class ThemeManager
{
public static ResourceDictionary GetThemeResourceDictionary(string theme)
{
if (theme != null)
{
Assembly assembly = Assembly.LoadFrom(“WPF.Themes.dll“);
string packUri = String.Format(@“/WPF.Themes;component/{0}/Theme.xaml“ theme);
return Application.LoadComponent(new Uri(packUri UriKind.Relative)) as ResourceDictionary;
}
return null;
}
public static string[] GetThemes()
{
string[] themes = new string[]
{
“expressionDark“ “expressionLight“ “RainierOrange“ “RainierPurple“ “RainierRadialBlue“
“ShinyBlue“ “ShinyRed“ “ShinyDarkTeal“ “ShinyDarkGreen“ “ShinyDarkPurple“
“DavesGlossyControls“ “WhistlerBlue“ “BureauBlack“ “BureauBlue“ “BubbleCreme“ “TwilightBlue“
“UXMusingsRed“ “UXMusingsGreen“ “UXMusingsRoughRed“ “UXMusingsRoughGreen“ “UXMusingsBubblyBlue“
};
return themes;
}
public static void ApplyTheme(this Application app string theme)
{
ResourceDictionary dictionary = ThemeManager.GetThemeResourceDictionary(theme);
if (dictionary != null)
{
app.Resources.MergedDictionaries.Clear();
app.Resources.MergedDictionaries.Add(dictionary);
}
}
public static void ApplyTheme(this ContentControl control string theme)
{
ResourceDictionary dictionary = ThemeManager.GetThemeResourceDictionary(theme);
if (dictionary != null)
{
control.Resources.MergedDictionaries.Clear();
control.Resources.MergedDictionaries.Add(dictionary);
}
}
#region Theme
///
/// Theme Attached Dependency Property
///
public static readonly DependencyProperty ThemeProperty =
DependencyProperty.RegisterAttached(“Theme“ typeof(string) typeof(ThemeManager)
new frameworkPropertymetadata((string)string.Empty
new PropertyChangedCallback(OnThemeChanged)));
///
/// Gets the Theme property. This dependency property
/// indicates ....
///
public static string GetTheme(Dependencyobject d)
{
return (string)d.GetValue(ThemeProperty);
}
///
/// Sets the Theme property. This dependency property
/// indicates ....
///
p
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
..A..H. 76800 2018-01-22 15:40 WPFTheme\.vs\WPF.Themes\v14\.suo
文件 2475008 2018-01-22 15:39 WPFTheme\WPF.Themes\bin\Debug\WPF.Themes.dll
文件 17920 2018-01-22 15:39 WPFTheme\WPF.Themes\bin\Debug\WPF.Themes.pdb
文件 459104 2014-10-24 17:39 WPFTheme\WPF.Themes\bin\Debug\WPFToolkit.dll
文件 342127 2009-09-09 19:24 WPFTheme\WPF.Themes\BubbleCreme\Theme.xaml
文件 325074 2009-09-09 19:24 WPFTheme\WPF.Themes\BureauBlack\Theme.xaml
文件 324746 2009-09-09 19:24 WPFTheme\WPF.Themes\BureauBlue\Theme.xaml
文件 162712 2009-09-09 19:24 WPFTheme\WPF.Themes\DavesGlossyControls\Theme.xaml
文件 269625 2009-09-09 19:24 WPFTheme\WPF.Themes\ex
文件 269631 2009-09-09 19:24 WPFTheme\WPF.Themes\ex
文件 142281 2018-01-22 15:39 WPFTheme\WPF.Themes\obj\Debug\BubbleCreme\Theme.baml
文件 162981 2018-01-22 15:39 WPFTheme\WPF.Themes\obj\Debug\BureauBlack\Theme.baml
文件 162620 2018-01-22 15:39 WPFTheme\WPF.Themes\obj\Debug\BureauBlue\Theme.baml
文件 85611 2018-01-22 15:39 WPFTheme\WPF.Themes\obj\Debug\DavesGlossyControls\Theme.baml
文件 7319 2018-01-22 15:38 WPFTheme\WPF.Themes\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 127027 2018-01-22 15:39 WPFTheme\WPF.Themes\obj\Debug\ex
文件 127027 2018-01-22 15:39 WPFTheme\WPF.Themes\obj\Debug\ex
文件 104343 2018-01-22 15:39 WPFTheme\WPF.Themes\obj\Debug\RainierOrange\Theme.baml
文件 104332 2018-01-22 15:39 WPFTheme\WPF.Themes\obj\Debug\RainierPurple\Theme.baml
文件 104251 2018-01-22 15:39 WPFTheme\WPF.Themes\obj\Debug\RainierRadialBlue\Theme.baml
文件 117334 2018-01-22 15:39 WPFTheme\WPF.Themes\obj\Debug\ShinyBlue\Theme.baml
文件 120354 2018-01-22 15:39 WPFTheme\WPF.Themes\obj\Debug\ShinyDarkGreen\Theme.baml
文件 103714 2018-01-22 15:39 WPFTheme\WPF.Themes\obj\Debug\ShinyDarkPurple\Theme.baml
文件 103862 2018-01-22 15:39 WPFTheme\WPF.Themes\obj\Debug\ShinyDarkTeal\Theme.baml
文件 117586 2018-01-22 15:39 WPFTheme\WPF.Themes\obj\Debug\ShinyRed\Theme.baml
文件 180813 2018-01-22 15:39 WPFTheme\WPF.Themes\obj\Debug\TwilightBlue\Theme.baml
文件 44992 2018-01-22 15:39 WPFTheme\WPF.Themes\obj\Debug\UXMusingsBubblyBlue\Theme.baml
文件 66595 2018-01-22 15:39 WPFTheme\WPF.Themes\obj\Debug\UXMusingsGreen\Theme.baml
文件 66595 2018-01-22 15:39 WPFTheme\WPF.Themes\obj\Debug\UXMusingsRed\Theme.baml
文件 125448 2018-01-22 15:39 WPFTheme\WPF.Themes\obj\Debug\UXMusingsRoughGreen\Theme.baml
............此处省略147个文件信息
评论
共有 条评论