Skip to content

Quick start (Versions before 5.0.0)

Simnico99 edited this page Mar 3, 2023 · 1 revision

Here is a really quick start to get you ready for using the new Mica material in your WPF app.

  1. To start Change the <Window><Window/> for <mica:MicaWindow></mica:MicaWindow>.
  2. Add the namespace by adding xmlns:mica="clr-namespace:MicaWPF.Controls;assembly=MicaWPF".

Here is an exemple:

<mica:MicaWindow  
        x:Class="MicaWPF.DesktopApp.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:MicaWPF.DesktopApp"
        mc:Ignorable="d"
        Title="MainWindow" 
        Height="450" 
        Width="800"
        xmlns:mica="clr-namespace:MicaWPF.Controls;assembly=MicaWPF" >
    <Grid>

    </Grid>
</mica:MicaWindow>

You also need to add these 2 resources to your App.xaml file: (Click here for MicaWPF version 5.0.0 and newer)

<Application
    x:Class="MicaWPF.Demo"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                  <!-- Note you can change this one to MicaLight -->
                  <ResourceDictionary Source="pack://application:,,,/MicaWPF;component/Styles/Themes/MicaDark.xaml" /> 
                  <ResourceDictionary Source="pack://application:,,,/MicaWPF;component/Styles/MicaWPF.xaml" />
              </ResourceDictionary.MergedDictionaries>
          </ResourceDictionary>
      </Application.Resources>
   </Application>

Now get into your Window code:

  1. Add the namespace using MicaWPF.Controls;.
  2. Change the Window inherited class to MicaWindow.

Here is an exemple of what it might look like using .NET6:

using MicaWPF.Controls;

namespace MicaWPF.DesktopApp;

public partial class MainWindow : MicaWindow
{
    public MainWindow()
    {
        InitializeComponent();
    }
}

Note For .Net5.0 and .Net6.0

You will need to change your CSPROJ to include the windows build after the netx.0-windows Here is an exemple using .Net6.0 just change the 6 for a 5 on .Net5.0

<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>

The result on Windows 11:
image

The result on Windows 10:
image