'Windows Template Studio (WinUI 3 in Desktop) - Customize TitleBar

I am a newbie and i am trying to customize the titlebar in the App. I have used Windows Template Studio to create a NavigationView Project for (winui 3 in Desktop) c#. The App does not create a MainWindow.xaml.

I've gone through the docs, which i have edited the app.xaml.cs to extendscontentintotitlebar = true. This works by extending the content area and removing the titlebar, but i don't know where i need to use settitlebar, since i don't have a mainwindow.xaml to set the UIelement.

    public partial class App : Application
    {
    public static Window MainWindow { get; set; } = new Window();

    public App()
    {
        InitializeComponent();
        UnhandledException += App_UnhandledException;
        Ioc.Default.ConfigureServices(ConfigureServices());
    }

    private void App_UnhandledException(object sender, UnhandledExceptionEventArgs e)
    {

    }

    protected override async void OnLaunched(LaunchActivatedEventArgs args)
    {
        base.OnLaunched(args);
        var activationService = Ioc.Default.GetService<IActivationService>();
        await activationService.ActivateAsync(args);

        MainWindow.Title = "AppDisplayName".GetLocalized();
        MainWindow.ExtendsContentIntoTitleBar = true;
    }

How or Where do i set the UIelement and settitlebar in code-behind for the App?

Hope this all makes sense.

Using: VS2019 Windows App SDK Windows Template Studio Windows 10

Jake



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source