我希望能够集中我的CommandBar的内容。我现在的代码是
<Page.BottomAppBar>
<CommandBar x:Name="BottomBar" Background="Black" Visibility="Collapsed" OverflowButtonVisibility="Collapsed" >
<CommandBar.PrimaryCommands>
<AppBarButton Name="btnSend" Icon="Forward" Foreground="White"/>
<AppBarButton Name="btnCancel" Icon="Clear" Foreground="White"/>
</CommandBar.PrimaryCommands>
<CommandBar.Content>
<TextBlock Name="tbBar" Text="EOOOOOOOOO" Foreground="White" Margin="12,14" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</CommandBar.Content>
</CommandBar>
</Page.BottomAppBar>这把内容放在左边,水平和垂直对齐,但我需要它在中间。
发布于 2018-10-10 12:00:01
我已经在我的博客这里上写过这件事,所以请浏览它以获得完整的细节。造成此问题的原因是“周年更新”中添加的IsDynamicOverflowEnabled属性。当设置为enabled时,Grid列Content of CommandBar驻留在set Width="Auto"中,这意味着它只给内容它实际需要的空间,并将所有剩余的空间保留给CommandBar按钮。
最简单的解决方案是将IsDynamicOverflowEnabled设置为false。如果要保留此特性,则必须修改CommandBar的默认模板。
<CommandBar HorizontalContentAlignment="Center"
IsDynamicOverflowEnabled="False">
<CommandBar.Content>
<TextBlock Text="Content" />
</CommandBar.Content>
</CommandBar>https://stackoverflow.com/questions/52738730
复制相似问题