• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

《WPF》UI框架MaterialDesignTheme的使用

武飞扬头像
古城少年白衣殇
帮助1

《WPF》UI框架MaterialDesignTheme的使用



前言

一边学习一边记录


一、MaterialDesignTheme是什么?

MaterialDesignTheme是由Google推出的开源免费的UI框架。

二、使用步骤

1.引入库

使用NuGet添加Material Design资源
学新通

1.配置资源

在App.xaml中需要编写

代码如下:

    <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.DeepPurple.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Lime.xaml" />
            </ResourceDictionary.MergedDictionaries>
	</ResourceDictionary>

也可以在里面添加主题颜色

   			<SolidColorBrush x:Key="PrimaryHueLightBrush" Color="#BBB" />
            <SolidColorBrush x:Key="PrimaryHueLightForegroundBrush" Color="#BBB" />
            <SolidColorBrush x:Key="PrimaryHueMidBrush" Color="#004098" />
            <SolidColorBrush x:Key="PrimaryHueMidForegroundBrush" Color="White" />
            <SolidColorBrush x:Key="PrimaryHueDarkBrush" Color="White" />
            <SolidColorBrush x:Key="PrimaryHueDarkForegroundBrush" Color="#004098" />
            <SolidColorBrush x:Key="SecondaryAccentBrush" Color="#004098" />
            <SolidColorBrush x:Key="SecondaryAccentForegroundBrush" Color="Yellow" />
            <SolidColorBrush x:Key="PrimaryLightBrush" Color="Red" />
            <SolidColorBrush x:Key="PrimaryLightForegroundBrush" Color="Green" />

2.控件样式

需要在窗体的头部添加 xmlns:materialDesign=“http://materialdesigninxaml.net/winfx/xaml/themes”

2.1TextBox样式

		//默认提示文字
		materialDesign:HintAssist.Hint="输入查询条件" 
		//默认提示文字是否会悬浮在文本框上
		materialDesign:HintAssist.IsFloating="False"
		

结束

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhiabbgf
系列文章
更多 icon
同类精品
更多 icon
继续加载