fluter
fluter

Reputation: 13836

Set inactive color for customized titlebar

I followed the uwp titlebar sample, it works fine except one thing, the color of the titlebar is always the same, but it should be different when the window is not in the foreground, I tried to use LayoutMetricsChanged and IsVisibleChanged to listen to the defocus event but it is not working, so how can I set the different color of the new bar and make it like a real one?

Upvotes: 1

Views: 606

Answers (1)

Arnaud Develay
Arnaud Develay

Reputation: 3970

Check this article : Eternal Coding - Take the control of your titlebar.

You will have to handle the event Window.Current.Activated. For example, here is the code extracted from the same article:

private void Current_Activated(object sender, WindowActivatedEventArgs e)
{
    if (e.WindowActivationState != CoreWindowActivationState.Deactivated)
    {
        BackButtonGrid.Visibility = Visibility.Visible;
        MainTitleBar.Opacity = 1;
    }
    else
    {
        BackButtonGrid.Visibility = Visibility.Collapsed;
        MainTitleBar.Opacity = 0.5;
    }
}

This snippet will update the opacity of its custom title bar when the window gains or losts focus.

Upvotes: 2

Related Questions