Getting started
Adding dictionaries
XAML, and hence WPF, operate on resource dictionaries. These are HTML-like files that describe the appearance and various aspects of the controls. WPF UI adds its own sets of these files to tell the application how the controls should look.
There should be a file called App.xaml
in your new application. Add new dictionaries to it using WPF UI ControlsDictionary
and ThemesDictionary
classes:
<Application
...
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ui:ThemesDictionary Theme="Dark" />
<ui:ControlsDictionary />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
Notice that the ThemeDictionary
lets you choose a color theme, Light
or Dark
.
The main window
There should be a MainWindow.xaml
file in your newly created application. It contains the arrangement of the controls used and their parameters.
<Window x:Class="WpfApp1.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:WpfApp1"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
</Grid>
</Window>
Add the WPF UI library namespace to this window to tell the XAML compiler that you will be using controls from the library.
<Window
...
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" />
Adding controls
To add a new control from the WPF UI library, just enter its class name, prefixing it with the ui:
prefix:
<Window x:Class="WpfApp1.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:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:local="clr-namespace:WpfApp1"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<ui:SymbolIcon Symbol="Fluent24"/>
</Grid>
</Window>
Well...
That's it when it comes to the basics, information about individual controls can be found in documentation. Rules for building a WPF application can be found in the official Microsoft documentation. You can check out how to build MVVM applications here.
If you think this documentation needs improvement, please help improve it here.