代码之家  ›  专栏  ›  技术社区  ›  wbk727

如何在CommandBar中更好地处理长项目名称

  •  0
  • wbk727  · 技术社区  · 5 年前

    是否有比默认设置更好的处理方式 CommandBar 有长文本的项目。字符长度因语言而异,因此有时可能无法看到项目文本是什么,因为 命令栏 扩展时会发生变化。

    XAML(法语)

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
    
        <CommandBar Grid.Row="0">
            <CommandBar.Content>
                <Button 
                    Style="{StaticResource NavigationBackButtonNormalStyle}" 
                    Name="BackButton" 
                    VerticalAlignment="Top" 
                    Click="Back_Click"/>
            </CommandBar.Content>
    
            <AppBarButton Icon="Mail" Label="Information sur le produit"/>
            <AppBarButton Icon="Mail" Label="Avis sur les produits"/>
            <AppBarButton Icon="Mail" Label="Informations de contact"/>
        </CommandBar>
        <Frame Name="MyFrame" Grid.Row="1"/>
    </Grid>
    

    XAML(英语)

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
    
        <CommandBar Grid.Row="0">
            <CommandBar.Content>
                <Button 
                    Style="{StaticResource NavigationBackButtonNormalStyle}" 
                    Name="BackButton" 
                    VerticalAlignment="Top" 
                    Click="Back_Click"/>
            </CommandBar.Content>
    
            <AppBarButton Icon="Mail" Label="Product information"/>
            <AppBarButton Icon="Mail" Label="Product reviews"/>
            <AppBarButton Icon="Mail" Label="Contact information"/>
        </CommandBar>
        <Frame Name="MyFrame" Grid.Row="1"/>
    </Grid>
    

    英语(已折叠)

    enter image description here

    英语(扩展)

    enter image description here

    法语(崩溃)

    enter image description here

    法语(扩展)

    enter image description here

    0 回复  |  直到 5 年前
        1
  •  0
  •   Nico Zhu    5 年前

    是否有比默认方法更好的方法来处理具有长文本的CommandBar项。

    制作太长的内容并不是更好的做法 CommandBar ,如果你确实想制作长篇内容,你可以设置 DefaultLabelPosition 这是对的。

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
    
        <CommandBar Grid.Row="0" DefaultLabelPosition="Right">
            <CommandBar.Content>
                <Button 
                Style="{StaticResource NavigationBackButtonNormalStyle}" 
                Name="BackButton" 
                VerticalAlignment="Top" 
                Click="Back_Click"/>
            </CommandBar.Content>
    
            <AppBarButton Icon="Mail" Label="Information sur le produit" />
            <AppBarButton Icon="Mail" Label="Avis sur les produits"/>
            <AppBarButton Icon="Mail" Label="Informations de contact"/>
        </CommandBar>
        <Frame Name="MyFrame" Grid.Row="1"/>
    </Grid>