首页 > 其他分享 >`MahApps.Metro` Quick Start

`MahApps.Metro` Quick Start

时间:2023-01-27 16:33:23浏览次数:52  
标签:MahApps Metro xaml Start Quick your

MahApps.Metro Quick Start

This guide will introduce you to how MahApps.Metro works and how to incorporate it into your app.

原则:xaml不要调用后台代码,后台代码调用xaml。

Installation

You can install MahApps.Metro via the NuGet UI or with the Package Manager Console.

具体步骤参见:Create a new F# WPF Code Behind Application

MahApps build-in styles and themes

All resources of MahApp.Metro are located within separate resource dictionaries. To adopt the MahApps.Metro theme, you will need to add the resource dictionaries to your App.xaml.

<Application 
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             >
  <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" />
        <!-- Theme setting -->
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Dark.Blue.xaml" />
      </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
  </Application.Resources>
</Application>

Note
Make sure that all resource file names are Case Sensitive!

Using the MetroWindow

To start with the full MahApps styling and full window support you need to change your normal Window to our MetroWindow.

  • Open up your main window, normally named MainWindow.xaml

  • Add the namespace attribute inside the opening Window tag

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

    or

    xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
    
  • Change the <Window ... </Window> tag to <mah:MetroWindow ... </mah:MetroWindow>

Now you should have something like this (don't copy and paste this directly)

<mah:MetroWindow 
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                 mc:Ignorable="d"                 
                 xmlns:mah="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"                 
                 Title="MainWindow" Width="800" Height="450" WindowStartupLocation="CenterScreen"
                 >
  <Grid>
    <!--  Your content  -->
  </Grid>
</mah:MetroWindow>

You'll also need to modify the code behind of the window file so that the base class matches the MetroWindow class of the XAML file.

But in most cases you can just drop the base class (because this is a partial class the XAML should take care of this).

type FirstMetroWindowXaml = FsXaml.XAML<"FirstMetroWindow.xaml">

type FirstMetroWindow () =
    inherit FirstMetroWindowXaml ()

The end result will look something like this:

img

What's Next?

For extended documentation, take a look at the Styles and Controls section.

文摘自官方文档:MahApps.Metro - Quick Start

标签:MahApps,Metro,xaml,Start,Quick,your
From: https://www.cnblogs.com/cuishengli/p/17069000.html

相关文章

  • QML入门教程(1): Qt Quick与QML介绍
    1什么是QtQucik?         QtQuick是QtSDK4.7中引入的一种新的界面开发框架,使用QtQuick,你可以快速、轻松地创建供移动和嵌入式设备使用的动态触摸式......
  • Cesium之Quick Start
    1.引言Cesium是一款三维地球和地图可视化开源JavaScript库,使用WebGL来进行硬件加速图形,使用时不需要任何插件支持,基于Apache2.0许可的开源程序,可以免费用于商业和非商业......
  • SpringBoot 使用 Sa-Token-Quick-Login 插件实现快速登录认证
    原文链接:  https://mp.weixin.qq.com/s/XxXVCFBoK7AjGznW5tzl7w   一、解决的问题 Sa-Token-Quick-Login可以为一个系统快速的、零代码注入一个登录页面 试......
  • B. Quick Sort【Codeforces Round #842 (Div. 2)】
    B.QuickSortYouaregivenapermutation【排列】†\(p\)oflength\(n\)andapositiveinteger\(k≤n\).Inoneoperation,you:Choose\(k\)distinctelement......
  • QuickSort
    importjava.util.Arrays;publicclassQuickSort{publicstaticvoidmain(String[]args){int[]nums={11,24,5,32,50,34,54,76};S......
  • delphi quick pdf library打印PDF很方便
    //事先需要安装foxitquickpdflibrary,安装完成,把DebenuPDFLibraryDLL1811.pas文件添加你的项目文件内//把DebenuPDFLibraryDLL1811.dll动态库复制到你执行程序目录......
  • 最强备注插件:quick note。
     我就直接把常用的代码往这里一放,用的时候我复制出来一搜,就找到对应的位置了。完美。根本不需要这个插件记录代码位置我感觉quicknote比codereadingnote好 ......
  • Could not resolve archetype org.apache.maven.archetypes:maven-archetype-quicksta
     之前都是命令行创建,今天用eclipse装m2eclipse的时候装完后创建项目的时候报错:Couldnotresolvearchetypeorg.apache.maven.archetypes:maven-archetype-quickstart:REL......
  • QTQuick控件基础(1)
    一、ItemQtQuick所有的可视项目都继承自Item,它定义了可视化项目所有通用特性(x\y\width\height\anchors等)具体包括1、作为容器2、不透明性没有设置opacity属性设置......
  • 拓端tecdat|R语言代写辅导使用Profviz进行Metropolis-in-Gibbs抽样和运行时间分析
     对于许多模型,如物流模型,没有共轭先验-所以Gibbs不适用。正如我们在第一篇文章中看到的那样,蛮力网格方法太慢而无法扩展到真实环境。这篇文章展示了我们如何使用Metropol......