我遵循了uwp titlebar示例 ,除了一件事之外,它都可以正常工作,titlebar的颜色始终相同,但是当窗口不在前景中时,它应该有所不同,我尝试使用LayoutMetricsChanged
和IsVisibleChanged
收听散焦事件,但它不起作用,那么如何设置新栏的不同颜色并使之像真实的呢?
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.