■ 머터리얼 디자인(Material Design)을 사용하는 방법을 보여준다.
▶ Project.csproj
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>WinExe</OutputType> <TargetFramework>net5.0-windows</TargetFramework> <UseWPF>true</UseWPF> <Authors>DSCore</Authors> <Company>DSCore</Company> <Copyright>Copyright © DSCore 2021</Copyright> </PropertyGroup> <ItemGroup> <ApplicationDefinition Include="MainApplication.xaml"> <Generator>MSBuild:Compile</Generator> </ApplicationDefinition> </ItemGroup> <ItemGroup> <PackageReference Include="MaterialDesignThemes" Version="4.2.1" /> </ItemGroup> </Project> |
▶ MainApplication.xaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<Application x:Class="TestProject.MainApplication" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="MainWindow.xaml"> <Application.Resources> <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> </Application.Resources> </Application> |
▶ MainWindow.xaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
<Window x:Class="TestProject.MainWindow" 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" Width="800" Height="600" Title="머터리얼 디자인(Material Design) 사용하기" Background="{DynamicResource MaterialDesignPaper}" FontFamily="나눔고딕코딩" FontSize="16"> <Grid> <materialDesign:Card HorizontalAlignment="Center" VerticalAlignment="Center" Padding="30" TextOptions.TextFormattingMode="Ideal" TextOptions.TextRenderingMode="Auto" TextElement.FontFamily="{DynamicResource MaterialDesignFont}" TextElement.FontSize="30" TextElement.FontWeight="Regular" TextElement.Foreground="{DynamicResource MaterialDesignBody}"> <TextBlock Style="{DynamicResource MaterialDesignTitleTextBlock}"> First Material Design App </TextBlock> </materialDesign:Card> </Grid> </Window> |