This article presents a simple login interface layout; it doesn't involve any significant functionality.
1. Final Effect

2. Business Scenario
Common business scenario.
3. Implementation
3.1 Adding NuGet Package
Create a WPF solution named "Login" using .NET Core 3.1, and add one NuGet package: MaterialDesignThemes.
3.2 Project Structure
Two files are modified:
- App.xaml: Add MD control styles
- MainWindow.xaml: Main window implementation
3.2.1 App.xaml – Incorporating MD Control Styles
Key style reference code
<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.MergedDictionaries>
<!--Primary-->
<SolidColorBrush x:Key="PrimaryHueLightBrush" Color="#FFCDD2" />
<SolidColorBrush x:Key="PrimaryHueLightForegroundBrush" Color="#FF333333" />
<SolidColorBrush x:Key="PrimaryHueMidBrush" Color="#f44336" />
<SolidColorBrush x:Key="PrimaryHueMidForegroundBrush" Color="#FFEEEEEE" />
<SolidColorBrush x:Key="PrimaryHueDarkBrush" Color="#b71c1c" />
<SolidColorBrush x:Key="PrimaryHueDarkForegroundBrush" Color="#FFFFFFFF" />
<!--Accent-->
<SolidColorBrush x:Key="SecondaryAccentBrush" Color="#ff1744" />
<SolidColorBrush x:Key="SecondaryAccentForegroundBrush" Color="#FFFFFF" />
</ResourceDictionary>
</Application.Resources>
3.2.2 MainWindow.xaml
Full code for the login window layout
<Window
x:Class="WpfApp2.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:local="clr-namespace:WpfApp2"
mc:Ignorable="d"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
Title="Login"
Height="450"
Width="800"
>
<Grid Background="#FF1E64AA">
<Grid Width="300" Height="400">
<Border
CornerRadius="3"
HorizontalAlignment="Center"
Width="290"
Height="350"
VerticalAlignment="Center"
Background="White"
Margin="0 35 0 0"
>
<StackPanel Margin="0 50 0 0">
<TextBlock
Text="Please log in to your account"
HorizontalAlignment="Center"
Foreground="Gray"
Margin="30"
FontSize="21"
FontFamily="Champagne & Limousines"
FontWeight="SemiBold"
/>
<TextBox Margin="20 10" materialDesign:HintAssist.Hint="Email" />
<PasswordBox Margin="20 10" materialDesign:HintAssist.Hint="Password" />
<Grid Margin="20 0">
<CheckBox Content="Remember me" HorizontalAlignment="Left" />
<TextBlock
Text="Forgot password?"
Foreground="#FF2259D1"
HorizontalAlignment="Right"
Cursor="Hand"
/>
</Grid>
<button Content="Login" Margin="20 30" />
</StackPanel>
</Border>
<Border
Width="70"
Height="70"
HorizontalAlignment="Center"
VerticalAlignment="Top"
Background="White"
CornerRadius="50"
>
<Border.Effect>
<DropShadowEffect BlurRadius="15" ShadowDepth="0" />
</Border.Effect>
<materialDesign:PackIcon
Kind="Mail"
Foreground="{StaticResource PrimaryHueMidBrush}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Width="25"
Height="25"
/>
</Border>
</Grid>
</Grid>
</Window>
4. References
- Video tutorial by the great Design com WPF: First Impressions and new VS 2019
- Open source control library: MaterialDesignInXamlToolkit
- Our introduction to the MD open source control library: Control Introduction
5. Code Download
GitHub source code: HelloDotNetCore