JamesHoux
JamesHoux

Reputation: 3447

Why is WPF Titlebar background white when I run program?

Xaml Designer shows the window titlebar as dark gray (default), but when I run the application, the titlebar is pure white.

Shouldn't the titlebar color use my windows theme settings? Why isn't it?

I started a brand New .NET Framework 4.6.2 WPF Application. I change absolutely nothing. I run the app, and I get the behavior described.

Here's the default XAML code for the main window:

<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"
    Title="MainWindow" Height="450" Width="800">
<Grid>

</Grid>

Here's App.xaml:

<Application x:Class="WpfApp2.App"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:local="clr-namespace:WpfApp2"
         StartupUri="MainWindow.xaml">
<Application.Resources>

</Application.Resources>

Upvotes: 1

Views: 565

Answers (1)

JamesHoux
JamesHoux

Reputation: 3447

I didn't realize this, but applications will use the default white titlebar unless you specifically check to apply theme accent to titlebar in windows theme settings.

The reason I was boggled by this at first is that the XAML designer window shows the window titlebar as dark gray in the design view. It changes to white at runtime. I mistakenly thought the dark gray titlebar was respecting the Dark Windows Theme. It's not! It's actually respecting the Dark Visual Studio theme.

Apparently, the theme of choice in Visual Studio determines the titlebar color in XAML designer, which gives a false appearance of what the application will look like when it runs.

I feel stupid for having posted the question to begin with, but I just thought there was some kind of XAML configuration point I didn't know about. :P

Upvotes: 2

Related Questions