我试图在我的UWP应用程序的底部使用CommandBar,但似乎无法摆脱底部的这种空隙。UWP CommandBar在底部有空隙
这是挺难看的,但它的存在的命令栏和窗口的底部边框之间。我尝试了各种各样的VerticalAlignment
配置,但似乎没有做到这一点。我创建了一个用户控制
<UserControl
x:Class="PivotalTrackerUWP.Controls.NavigationControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:PivotalTrackerUWP.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:svg="using:Mntone.SvgForXaml.UI.Xaml"
mc:Ignorable="d"
d:DesignHeight="50"
d:DesignWidth="400">
<Grid Height="50" VerticalAlignment="Bottom">
<StackPanel VerticalAlignment="Bottom">
<CommandBar Height="50">
<CommandBar.SecondaryCommands>
<AppBarButton Label="Preferences"/>
<AppBarSeparator/>
<AppBarButton Label="My Account"/>
<AppBarButton Label="Logout" Click="LogoutButton_Click"/>
</CommandBar.SecondaryCommands>
</CommandBar>
</StackPanel>
</Grid>
</UserControl>
我然后使用在bottom.When在设计主电网内我的其他XAML页面此这种控制用户控件也有仍处于底部的那个差距如此之我认为这与控制中的XAML有关。
这将工作出色,但我使用UserControl为了重用代码,我并不想在每个页面上为BottomAppBar添加XAML。 –
如果出现这种情况,可以参考我的链接答案,在App.Xaml中为命令栏指定不同的紧凑高度,或者直接删除所有硬编码的高度值。 –
我在你的链接答案中使用了解决方案,它可以工作,谢谢! –