AppBar显示了一半的内容

时间:2016-02-06 18:41:00

标签: c# windows xaml windows-phone uwp

我将AppBar用于我的应用程序和AppBarButtons。

但ABB在开放AB后只显示了一半的标题文本和休息。 我想完全隐藏文本并仅在打开AB时显示。

Problem image

<Page.Resources>
    <Style TargetType="AppBarButton" x:Name="appBar">
        <Setter Property="VerticalAlignment" Value="Top"/>
        <Setter Property="HorizontalAlignment" Value="Right"/>
    </Style>
</Page.Resources>

<Page.BottomAppBar>
    <AppBar IsSticky="True" ClosedDisplayMode="Compact" Background="LightGray" >

        <StackPanel Orientation="Horizontal" VerticalAlignment="Top" FlowDirection="RightToLeft" >
            <AppBarButton x:Name="mapaStackPanel" Label="Mapa" Icon="Map" Click="MapaStackPanelClick" Style="{StaticResource appBar}" Visibility="Collapsed" />
            <AppBarButton x:Name="mojePolohaStackPanel"  Label="Moje poloha" Icon="Map" Click="MojePolohaClick" Style="{StaticResource appBar}"/>
            <AppBarButton x:Name="najdiNejblizsiStackPanel"  Label="Najdi Nejbližší" Icon="Map" Click="NajdiNejblizsiClick" Style="{StaticResource appBar}"/>
            <AppBarButton x:Name="navigujStackPanel" Label="Naviguj" Icon="Directions" Click="navigujStackPanel_Click" Visibility="Collapsed" Style="{StaticResource appBar}"/>
        </StackPanel>
    </AppBar>
</Page.BottomAppBar>

谢谢你, VT

1 个答案:

答案 0 :(得分:0)

使用CommandBar代替AppBar,因为它旨在为AppBarButton及相关命令元素提供布局。

<Page.BottomAppBar>
    <CommandBar IsSticky="True" ClosedDisplayMode="Compact" Background="LightGray" >
        <AppBarButton x:Name="mapaStackPanel" Label="Mapa" Icon="Map" Click="MapaStackPanelClick" Style="{StaticResource appBar}" Visibility="Collapsed" />
        <AppBarButton x:Name="mojePolohaStackPanel"  Label="Moje poloha" Icon="Map" Click="MojePolohaClick" Style="{StaticResource appBar}"/>
        <AppBarButton x:Name="najdiNejblizsiStackPanel"  Label="Najdi Nejbližší" Icon="Map" Click="NajdiNejblizsiClick" Style="{StaticResource appBar}"/>
        <AppBarButton x:Name="navigujStackPanel" Label="Naviguj" Icon="Directions" Click="navigujStackPanel_Click" Visibility="Collapsed" Style="{StaticResource appBar}"/>
    </CommandBar>
</Page.BottomAppBar>