• WPF_MahApps.Metro界面主题使用


    一、创建WPF项目:
    在这里插入图片描述
    二、下载MahApps.Metro:
    在这里插入图片描述
    三、修改MainWindow.xaml
    1.添加一栏:

                     xmlns:mah="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
    

    2.修改开头为:

    <mah:MetroWindow x:Class="demo.MainWindow"
    

    结尾也要修改。

    四、修改MainWindow.xalm.cs
    1.修改窗体继承:

    namespace demo
    {
        /// <summary>
        /// MainWindow.xaml 的交互逻辑
        /// </summary>
        public partial class MainWindow : MetroWindow//由Window修改
        {
            public MainWindow()
            {
                InitializeComponent();
            }
        }
    }
    

    五、修改App.xaml
    1.MahApps.Metro,2.0版本以上修改如下:

        <Application.Resources>
            <ResourceDictionary>
                <ResourceDictionary.MergedDictionaries>
                    <!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
                    <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
                    <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
                    <!-- Accent and AppTheme setting -->
                    <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Blue.xaml" />
                </ResourceDictionary.MergedDictionaries>
            </ResourceDictionary>
        </Application.Resources>
    

    2.MahApps.Metro,1.65版本以及更早版本修改如下:

      <Application.Resources>
        <ResourceDictionary>
          <ResourceDictionary.MergedDictionaries>
            <!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
            <!-- Accent and AppTheme setting -->
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
          </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
      </Application.Resources>
    </Application>
    

    六、运行界面展示:
    在这里插入图片描述
    范例程序下载:demo.rar

  • 相关阅读:
    echarts更改鼠标悬浮时的文字
    echarts加定值横线
    js属性对象的hasOwnProperty方法
    React中使用回车键绑定事件
    使用html2canvas插件截图不全的问题,亲测有效!!!
    Windows用Putty以及Pageant配置SSH用于Github等身份验证
    andThenDemo 和Predicate的函数式
    延迟方法的调用---排列数字的大小(Supplier)
    延迟方法的调用---日志错误等级的输出(Supplier)
    延迟方法的调用---日志错误等级的输出
  • 原文地址:https://www.cnblogs.com/LcVong/p/15460104.html
Copyright © 2020-2023  润新知