【问题标题】:How to add an AcrylicBrush to the toolbar only in UWP如何仅在 UWP 中将 AcrylicBrush 添加到工具栏
【发布时间】:2019-01-11 07:32:24
【问题描述】:

如何仅在 UWP 中将丙烯酸材料应用于TitleBar(就像 Microsoft Edge)。在像枢轴这样的场景中。您使用将视图扩展到标题栏。但是如果它只是一个普通的单页应用,你想把标题栏做成亚克力呢

【问题讨论】:

  • 那么有人知道吗?

标签: xaml uwp titlebar fluent-design acrylic-material


【解决方案1】:

您使用将视图扩展到标题栏。但是如果它只是一个普通的单页应用,你想把标题栏做成亚克力呢

你的理解是正确的。标题栏亚克力,只适用于单页。对于 Edge 设计,它将 TitleBar ButtonBackgroundColor,ButtonInactiveBackgroundColor 设置为透明。并将 ExtendViewIntoTitleBar 属性设置为 true 以将您的内容扩展到 TitleBar。然后在底部区域做一个等高的亚克力元素。

private void ExtendAcrylicIntoTitleBar()
{
    CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
    CoreApplication.GetCurrentView().TitleBar.LayoutMetricsChanged += (s,e) => {
       Header.Height = s.Height;
   };

    ApplicationViewTitleBar titleBar = ApplicationView.GetForCurrentView().TitleBar;
    titleBar.ButtonBackgroundColor = Colors.Transparent;
    titleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
}

<Rectangle Name="Header"
Stretch="UniformToFill" 
Fill="{ThemeResource SystemControlChromeHighAcrylicWindowMediumBrush}" 
VerticalAlignment="Top"/>

【讨论】:

  • 但问题是当我将视图扩展到标题栏时。我需要设置上边距。使顶部的元素变得可点击。我认为如果某些属性(如 applicationView.GetForCurrentView().TitleBar.BackgroundColor 可以接受 Brush 而不是 Color
  • 嗨@AdhamAli 但是不支持将刷子设置为TitleBar.BackgroundColor,如果您确实需要此功能,请随时在UserVoice 上询问此功能。如果答案有帮助,请考虑接受。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-12-02
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多