Change height of Bottom AppBar in XAML UWP

陌路散爱 提交于 2019-12-01 05:38:40

问题


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>

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


回答1:


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>

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.



来源:https://stackoverflow.com/questions/37465394/change-height-of-bottom-appbar-in-xaml-uwp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!