How do I customize the Window Titlebar in a Windows App SDK (WIN UI/Project Reunion) Project?

908 Views Asked by At

I'm trying to build an app using the new Widows App SDK. I used the Windows Community Toolkit to create the application.

After consulting the documentation, I tried this:

On the first page that my app displays, I created a Textblock:

<TextBlock Text="Hello" x:Name="CustomTitleBar" /> 

In this page's code behind, I added the following code:

 private void Page_Loaded(object sender, RoutedEventArgs e)
 {
   App.MainWindow.ExtendsContentIntoTitleBar = true;
   App.MainWindow.SetTitleBar(CustomTitleBar);
   App.MainWindow.Activate();
 }

On the App XAML page I followed the doumentation's directions to override these values:

<SolidColorBrush x:Key="WindowCaptionBackground">Green</SolidColorBrush>
<SolidColorBrush x:Key="WindowCaptionBackgroundDisabled">LightGreen</SolidColorBrush>
<SolidColorBrush x:Key="WindowCaptionForeground">Red</SolidColorBrush>
<SolidColorBrush x:Key="WindowCaptionForegroundDisabled">Pink</SolidColorBrush> 

This above does make the default titlebar go away. However, I am left with just the word "Hello" with no background or buttons:

Screenshot of "titlebar"

Is there something I'm missing?

0

There are 0 best solutions below