在 XAML UWP 中更改底部 AppBar 的高度 [英] Change height of Bottom AppBar in XAML UWP
问题描述
有什么办法可以降低 XAML UWP 中底部 AppBar
的高度?我有以下 XAML 代码:
Is there any way to decrease the height of Bottom AppBar
in XAML UWP? I have the below XAML code:
<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 正上方有一个额外的空白区域.如果我使用黑色或蓝色作为背景色,则该空白区域会呈现白色
Problem is, when I set height to 35 or below 50, I see an extra blank space just above the bottom AppBar. And if I use Black or Blue as background colour, that blank space renders with white colour
推荐答案
解决此问题的最简单方法是覆盖 App.xaml.cs
文件中的相应主题资源.
The easist way to fix this is to override the corresponding theme resource in the App.xaml.cs
file.
<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>
我发现这个预定义资源的方式是,首先我用谷歌搜索了默认的Style
,然后我基本上只是翻了一下,找到了与 Height 相关的那些.
The way I found this predefined resource is, first I googled up the default Style
of the CommandBar
, then I basically just went through and found the ones that are related to Height.
这篇关于在 XAML UWP 中更改底部 AppBar 的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!