WPF Material Design for the first time

foreword

The full name of MD is MaterialDesignInXamlToolkit. Like Bootstrap, MaterialDesign is a UI style library. It is equivalent to casual clothes, Hanfu, and jeans in clothes, but it is a Ui framework with different styles.

related resources

insert image description here
Github address
insert image description here

MD instance resource download address
insert image description here

insert image description here

quick start

Quick Start Address

If it is an ordinary WPF program, make the following settings in App.xaml

<Application x:Class="Example.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
             StartupUri="MainWindow.xaml">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <materialDesign:BundledTheme BaseTheme="Light" PrimaryColor="DeepPurple" SecondaryColor="Lime" />
                <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" /> 
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>

Open the example Demo

insert image description here

The MainWindow.xaml code is as follows

<Window x:Class="WPF.MainWindow"
        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"
        xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
        xmlns:local="clr-namespace:WPF"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <Button
                IsEnabled="{Binding DataContext.ControlsEnabled, RelativeSource={RelativeSource FindAncestor, AncestorType=Window}}"
                Style="{ 
        StaticResource MaterialDesignFloatingActionMiniLightButton}"
                ToolTip="MaterialDesignFloatingActionMiniLightButton">
            <materialDesign:PackIcon Width="30"
                                     Height="30"
                                     Kind="Alarm" />
        </Button>
    </Grid>
</Window>

insert image description here
Indicates that the import was successful

You can use the desired components on the left side for rapid UI development, click on the lower right corner and there is a click case code

insert image description here

Tucao

Prism is an intrusive framework, that is, it gives you a full set of solutions, but you must solve it according to the solution given by Prism. It's too intrusive, I don't like it very much, I'd better write it myself.

おすすめ

転載: blog.csdn.net/qq_44695769/article/details/132549248