我試圖在我的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中爲命令欄指定不同的緊湊高度,或者直接刪除所有硬編碼的高度值。 –
我在你的鏈接答案中使用瞭解決方案,它可以工作,謝謝! –