【问题标题】:Change height of Bottom AppBar in XAML UWP在 XAML UWP 中更改底部 AppBar 的高度
【发布时间】:2016-09-24 17:25:17
【问题描述】:

有什么方法可以降低 XAML UWP 中底部 AppBar 的高度?我有以下 XAML 代码:

<Page.BottomAppBar>
    <CommandBar Height="35">
        <CommandBar.SecondaryCommands>
            <AppBarButton Label="Share"/>
            <AppBarButton Label="Settings"/>
            <AppBarButton Label="Settings"/>
            <AppBarButton Label="Settings"/>
            <AppBarButton Label="Settings"/>
            <AppBarButton Label="Settings"/>
            <AppBarButton Label="Settings"/>
        </CommandBar.SecondaryCommands>
    </CommandBar>
</Page.BottomAppBar>

问题是,当我将高度设置为 35 或低于 50 时,我看到底部 AppBar 上方有一个额外的空白区域。如果我使用黑色或蓝色作为背景色,则该空白区域会呈现为白色

【问题讨论】:

  • 你找到解决办法了吗?

标签: xaml uwp uwp-xaml


【解决方案1】:

解决此问题的最简单方法是覆盖App.xaml.cs 文件中的相应主题资源。

<Application
    x:Class="MyApp.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:MyApp"
    RequestedTheme="Light">

    <Application.Resources>
        <x:Double x:Key="AppBarThemeCompactHeight">35</x:Double>
    </Application.Resources>
</Application>

我找到这个预定义资源的方法是,首先我搜索了CommandBar 的默认Style,然后我基本上只是通过并找到与Height相关的那些。

【讨论】:

    猜你喜欢
    • 2020-05-29
    • 2018-05-26
    • 2019-08-16
    • 2020-01-02
    • 2016-11-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-21
    • 1970-01-01
    相关资源
    最近更新 更多