[UWP]如何在Uwp中删除/隐藏AppBarButton中的椭圆/虚线按钮 [英] [UWP]How to remove/hide ellipse/dotted button in AppBarButton in Uwp

查看:86
本文介绍了[UWP]如何在Uwp中删除/隐藏AppBarButton中的椭圆/虚线按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Uwp中删除/隐藏AppBarButton中的椭圆/虚线按钮

解决方案

嗨Elezard,


我看到你在这个论坛上发布了类似的问题:
https://social.msdn.microsoft.com/Forums/ windowsapps / zh-CN / 54d4c8d2-5755-48e5-b170-42a4a5f42ab6 / how-to-display-the-label-not-the-icon-in-appbarbutton-in-uwp?forum = wpdevelop


Nordine关于为ApplicationBar创建自定义样式的建议将是正确的方向。但他没有非常清楚地解释,你可能还没有完全理解它。


您想让标签始终显示在ApplicationBar中并隐藏图标,然后您需要编辑其默认样式。你可以"正确使用ApplicationBar - >编辑风格 - >编辑副本",然后您将看到默认样式。


在样式中,您可以找到名为"Content"的"ContentPresenter"控件。此控件用于显示图标。如果您不想显示它,可以将其"可见性"属性指定为"折叠"。然后你需要改变一些
的视觉状态,因为有些状态,标签会被动画隐藏。


以下是我的代码示例:

< Page.Resources> 
< Style x:Key =" AppBarButtonStyle1"的TargetType = QUOT; AppBarButton">
< Setter Property =" Background" Value =" {ThemeResource AppBarButtonBackground}" />
< Setter Property =" Foreground" Value =" {ThemeResource AppBarButtonForeground}" />
< Setter Property =" BorderBrush" Value =" {ThemeResource AppBarButtonBorderBrush}" />
< Setter Property =" Horizo​​ntalAlignment"值= QUOT;左" />
< Setter Property =" VerticalAlignment"值= QUOT;顶部和QUOT; />
< Setter Property =" FontFamily" Value =" {ThemeResource ContentControlThemeFontFamily}" />
< Setter Property =" FontWeight"值= QUOT;正常" />
< Setter Property =" Width"值= QUOT 68 QUOT; />
< Setter Property =" UseSystemFocusVisuals"值= QUOT;真" />
< Setter Property =" AllowFocusOnInteraction"值= QUOT假QUOT; />
< Setter Property =" Template">
< Setter.Value>
< ControlTemplate TargetType =" AppBarButton">
< Grid x:Name =" Root" BorderBrush =" {TemplateBinding BorderBrush}" BorderThickness =" {TemplateBinding BorderThickness}" Background =" {TemplateBinding Background}" MaxWidth =" {TemplateBinding MaxWidth}" MinWidth =" {TemplateBinding MinWidth}">
< Grid.Resources>
< Style x:Name =" LabelOnRightStyle"的TargetType = QUOT; AppBarButton">
< Setter Property =" Width"值= QUOT; NaN的" />
< / Style>
< /Grid.Resources>
< VisualStateManager.VisualStateGroups>
< VisualStateGroup x:Name =" ApplicationViewStates">
< VisualState x:Name =" FullSize" />
< VisualState x:Name =" Compact">
< Storyboard>
< ObjectAnimationUsingKeyFrames Storyboard.TargetProperty =" Visibility" Storyboard.TargetName = QUOT;为textLabel">
< DiscreteObjectKeyFrame KeyTime =" 0"值= QUOT;可见" />
< / ObjectAnimationUsingKeyFrames>
< / Storyboard>
< / VisualState>

< VisualState x:Name =" LabelOnRight">
< Storyboard>
< ObjectAnimationUsingKeyFrames Storyboard.TargetProperty =" Margin" Storyboard.TargetName = QUOT;内容和QUOT;>
< DiscreteObjectKeyFrame KeyTime =" 0"值= QUOT; 12,14,0,14" />
< / ObjectAnimationUsingKeyFrames>
< ObjectAnimationUsingKeyFrames Storyboard.TargetProperty =" MinHeight" Storyboard.TargetName = QUOT; ContentRoot">
< DiscreteObjectKeyFrame KeyTime =" 0" Value =" {ThemeResource AppBarThemeCompactHeight}" />
< / ObjectAnimationUsingKeyFrames>
< ObjectAnimationUsingKeyFrames Storyboard.TargetProperty ="(Grid.Row)" Storyboard.TargetName = QUOT;为textLabel">
< DiscreteObjectKeyFrame KeyTime =" 0"值= QUOT; 0" />
< / ObjectAnimationUsingKeyFrames>
< ObjectAnimationUsingKeyFrames Storyboard.TargetProperty ="(Grid.Column)" Storyboard.TargetName = QUOT;为textLabel">
< DiscreteObjectKeyFrame KeyTime =" 0"值= QUOT 1 QUOT; />
< / ObjectAnimationUsingKeyFrames>
< ObjectAnimationUsingKeyFrames Storyboard.TargetProperty =" TextAlignment" Storyboard.TargetName = QUOT;为textLabel">
< DiscreteObjectKeyFrame KeyTime =" 0"值= QUOT;左" />
< / ObjectAnimationUsingKeyFrames>
< ObjectAnimationUsingKeyFrames Storyboard.TargetProperty =" Margin" Storyboard.TargetName = QUOT;为textLabel">
< DiscreteObjectKeyFrame KeyTime =" 0"值= QUOT; 8,15,12,17" />
< / ObjectAnimationUsingKeyFrames>
< / Storyboard>
< / VisualState>
< VisualState x:Name =" LabelCollapsed">
< Storyboard>
< ObjectAnimationUsingKeyFrames Storyboard.TargetProperty =" MinHeight" Storyboard.TargetName = QUOT; ContentRoot">
< DiscreteObjectKeyFrame KeyTime =" 0" Value =" {ThemeResource AppBarThemeCompactHeight}" />
< / ObjectAnimationUsingKeyFrames>
< ObjectAnimationUsingKeyFrames Storyboard.TargetProperty =" Visibility" Storyboard.TargetName = QUOT;为textLabel">
< DiscreteObjectKeyFrame KeyTime =" 0"值= QUOT;可见" />
< / ObjectAnimationUsingKeyFrames>
< / Storyboard>
< / VisualState>
< VisualState x:Name =" Overflow">
< Storyboard>
< ObjectAnimationUsingKeyFrames Storyboard.TargetProperty =" Visibility" Storyboard.TargetName = QUOT; ContentRoot">
< DiscreteObjectKeyFrame KeyTime =" 0"值= QUOT;折叠" />
< / ObjectAnimationUsingKeyFrames>
< ObjectAnimationUsingKeyFrames Storyboard.TargetProperty =" Visibility" Storyboard.TargetName = QUOT; OverflowTextLabel">
< DiscreteObjectKeyFrame KeyTime =" 0"值= QUOT;可见" />
< / ObjectAnimationUsingKeyFrames>
< / Storyboard>
< / VisualState>
< VisualState x:Name =" OverflowWithToggleButtons">
< Storyboard>
< ObjectAnimationUsingKeyFrames Storyboard.TargetProperty =" Visibility" Storyboard.TargetName = QUOT; ContentRoot">
< DiscreteObjectKeyFrame KeyTime =" 0"值= QUOT;折叠" />
< / ObjectAnimationUsingKeyFrames>
< ObjectAnimationUsingKeyFrames Storyboard.TargetProperty =" Visibility" Storyboard.TargetName = QUOT; OverflowTextLabel">
< DiscreteObjectKeyFrame KeyTime =" 0"值= QUOT;可见" />
< / ObjectAnimationUsingKeyFrames>
< ObjectAnimationUsingKeyFrames Storyboard.TargetProperty =" Margin" Storyboard.TargetName = QUOT; OverflowTextLabel">
< DiscreteObjectKeyFrame KeyTime =" 0"值= QUOT; 38,0,12,0" />
< / ObjectAnimationUsingKeyFrames>
< / Storyboard>
< / VisualState>
< / VisualStateGroup>
< VisualStateGroup x:Name =" CommonStates">
< VisualState x:Name =" Normal">
< Storyboard>
< PointerUpThemeAnimation Storyboard.TargetName =" OverflowTextLabel" />
< / Storyboard>
< / VisualState>
< VisualState x:Name =" PointerOver">
< Storyboard>
< ObjectAnimationUsingKeyFrames Storyboard.TargetProperty =" Background" Storyboard.TargetName = QUOT;根和QUOT;>
< DiscreteObjectKeyFrame KeyTime =" 0" Value =" {ThemeResource AppBarButtonBackgroundPointerOver}" />
< / ObjectAnimationUsingKeyFrames>
< ObjectAnimationUsingKeyFrames Storyboard.TargetProperty =" BorderBrush" Storyboard.TargetName = QUOT;根和QUOT;>
< DiscreteObjectKeyFrame KeyTime =" 0" Value =" {ThemeResource AppBarButtonBorderBrushPointerOver}" />
< / ObjectAnimationUsingKeyFrames>
< ObjectAnimationUsingKeyFrames Storyboard.TargetProperty =" Foreground" Storyboard.TargetName = QUOT;内容和QUOT;>
< DiscreteObjectKeyFrame KeyTime =" 0" Value =" {ThemeResource AppBarButtonForegroundPointerOver}" />
< / ObjectAnimationUsingKeyFrames>
< ObjectAnimationUsingKeyFrames Storyboard.TargetProperty =" Foreground" Storyboard.TargetName = QUOT;为textLabel">
< DiscreteObjectKeyFrame KeyTime =" 0" Value =" {ThemeResource AppBarButtonForegroundPointerOver}" />
< / ObjectAnimationUsingKeyFrames>
< ObjectAnimationUsingKeyFrames Storyboard.TargetProperty =" Foreground" Storyboard.TargetName = QUOT; OverflowTextLabel">
< DiscreteObjectKeyFrame KeyTime =" 0" Value =" {ThemeResource AppBarButtonForegroundPointerOver}" />
< / ObjectAnimationUsingKeyFrames>
< PointerUpThemeAnimation Storyboard.TargetName =" OverflowTextLabel" />
< / Storyboard>
< / VisualState>
< VisualState x:Name =" Pressed">
< Storyboard>
< ObjectAnimationUsingKeyFrames Storyboard.TargetProperty =" Background" Storyboard.TargetName = QUOT;根和QUOT;>
< DiscreteObjectKeyFrame KeyTime =" 0" Value =" {ThemeResource AppBarButtonBackgroundPressed}" />
< / ObjectAnimationUsingKeyFrames>
< ObjectAnimationUsingKeyFrames Storyboard.TargetProperty =" BorderBrush" Storyboard.TargetName = QUOT;根和QUOT;>
< DiscreteObjectKeyFrame KeyTime =" 0" Value =" {ThemeResource AppBarButtonBorderBrushPressed}" />
< / ObjectAnimationUsingKeyFrames>
< ObjectAnimationUsingKeyFrames Storyboard.TargetProperty =" Foreground" Storyboard.TargetName = QUOT;内容和QUOT;>
< DiscreteObjectKeyFrame KeyTime =" 0" Value =" {ThemeResource AppBarButtonForegroundPressed}" />
< / ObjectAnimationUsingKeyFrames>
< ObjectAnimationUsingKeyFrames Storyboard.TargetProperty =" Foreground" Storyboard.TargetName = QUOT;为textLabel">
< DiscreteObjectKeyFrame KeyTime =" 0" Value =" {ThemeResource AppBarButtonForegroundPressed}" />
< / ObjectAnimationUsingKeyFrames>
< ObjectAnimationUsingKeyFrames Storyboard.TargetProperty =" Foreground" Storyboard.TargetName = QUOT; OverflowTextLabel">
< DiscreteObjectKeyFrame KeyTime =" 0" Value =" {ThemeResource AppBarButtonForegroundPressed}" />
< / ObjectAnimationUsingKeyFrames>
< PointerDownThemeAnimation Storyboard.TargetName =" OverflowTextLabel" />
< / Storyboard>
< / VisualState>
< VisualState x:Name =" Disabled">
< Storyboard>
< ObjectAnimationUsingKeyFrames Storyboard.TargetProperty =" Background" Storyboard.TargetName = QUOT;根和QUOT;>
< DiscreteObjectKeyFrame KeyTime =" 0" Value =" {ThemeResource AppBarButtonBackgroundDisabled}" />
< / ObjectAnimationUsingKeyFrames>
< ObjectAnimationUsingKeyFrames Storyboard.TargetProperty =" BorderBrush" Storyboard.TargetName = QUOT;根和QUOT;>
< DiscreteObjectKeyFrame KeyTime =" 0" Value =" {ThemeResource AppBarButtonBorderBrushDisabled}" />
< / ObjectAnimationUsingKeyFrames>
< ObjectAnimationUsingKeyFrames Storyboard.TargetProperty =" Foreground" Storyboard.TargetName = QUOT;内容和QUOT;>
< DiscreteObjectKeyFrame KeyTime =" 0" Value =" {ThemeResource AppBarButtonForegroundDisabled}" />
< / ObjectAnimationUsingKeyFrames>
< ObjectAnimationUsingKeyFrames Storyboard.TargetProperty =" Foreground" Storyboard.TargetName = QUOT;为textLabel">
< DiscreteObjectKeyFrame KeyTime =" 0" Value =" {ThemeResource AppBarButtonForegroundDisabled}" />
< / ObjectAnimationUsingKeyFrames>
< ObjectAnimationUsingKeyFrames Storyboard.TargetProperty =" Foreground" Storyboard.TargetName = QUOT; OverflowTextLabel">
< DiscreteObjectKeyFrame KeyTime =" 0" Value =" {ThemeResource AppBarButtonForegroundDisabled}" />
< / ObjectAnimationUsingKeyFrames>
< / Storyboard>
< / VisualState>
< / VisualStateGroup>
< VisualStateGroup x:Name =" InputModeStates">
< VisualState x:Name =" InputModeDefault" />
< VisualState x:Name =" TouchInputMode">
< VisualState.Setters>
< Setter Target =" OverflowTextLabel.Padding"值= QUOT; 0,11,0,13" />
< /VisualState.Setters>
< / VisualState>
< VisualState x:Name =" GameControllerInputMode">
< VisualState.Setters>
< Setter Target =" OverflowTextLabel.Padding"值= QUOT; 0,11,0,13" />
< /VisualState.Setters>
< / VisualState>
< / VisualStateGroup>
< /VisualStateManager.VisualStateGroups>
< Grid x:Name =" ContentRoot" MinHeight =" {ThemeResource AppBarThemeMinHeight}">
< Grid.ColumnDefinitions>
< ColumnDefinition Width =" *" />
< ColumnDefinition Width =" Auto" />
< /Grid.ColumnDefinitions>
< Grid.RowDefinitions>
< RowDefinition Height =" Auto" />
< RowDefinition Height =" Auto" />
< /Grid.RowDefinitions>
< ContentPresenter x:Name =" Content" Visibility =" Collapsed" AutomationProperties.AccessibilityView =" Raw" Content =" {TemplateBinding Icon}" Foreground =" {TemplateBinding Foreground}"的Horizo​​ntalAlignment = QUOT;拉伸"高度= QUOT; 20"余量= QUOT; 0,14,0,4" />
< TextBlock x:Name =" TextLabel" Foreground =" {TemplateBinding Foreground}"字号= QUOT; 12英寸FontFamily =" {TemplateBinding FontFamily}"余量= QUOT; 2,0,2,6" Grid.Row = QUOT 1 QUOT; TextAlignment = QUOT;中心" TextWrapping = QUOT;包覆与QUOT; Text =" {TemplateBinding Label}" />
< / Grid>
< TextBlock x:Name =" OverflowTextLabel" Foreground =" {TemplateBinding Foreground}"字号= QUOT; 15" FontFamily =" {TemplateBinding FontFamily}"的Horizo​​ntalAlignment = QUOT;拉伸"余量= QUOT; 12,0,12,0"填充= QUOT; 0,5,0,7" TextAlignment = QUOT;左" TextWrapping = QUOT; NoWrap的" Text =" {TemplateBinding Label}"的TextTrimming = QUOT;剪辑QUOT;能见度= QUOT;折叠" VerticalAlignment = QUOT;中心" />
< / Grid>
< / ControlTemplate>
< /Setter.Value>
< / Setter>
< / Style>
< /Page.Resources>

< Grid Background =" {ThemeResource ApplicationPageBackgroundThemeBrush}">

< / Grid>
< Page.BottomAppBar>
< CommandBar IsOpen =" True" IsSticky = QUOT;真">
< AppBarButton Label =" lab1" Style =" {StaticResource AppBarButtonStyle1}">< / AppBarButton>
< / CommandBar>
< /Page.BottomAppBar>

最好的问候,


Xavier Eoro



How to remove/hide ellipse/dotted button in AppBarButton in Uwp

解决方案

Hi Elezard,

I saw that you’ve posted a similar question on this forum: https://social.msdn.microsoft.com/Forums/windowsapps/en-US/54d4c8d2-5755-48e5-b170-42a4a5f42ab6/how-to-display-the-label-not-the-icon-in-appbarbutton-in-uwp?forum=wpdevelop

Nordine’s suggestion on creating a custom style for ApplicationBar would be on the right direction. But he has not explained very clearly, you might have not understood it entirely.

You want to make the lable always show in ApplicationBar and hide the Icon, then you would need to edit its default style. You could "right the ApplicationBar -> edit style -> edit a copy", then you will see the default style.

In the style, you could find the "ContentPresenter" control which is named as "Content". This control is used to show the Icon. If you do not want to show it, you could specify its "Visibility" property to "Collapsed". Then you would need to change some visual state, because is some states, the lable would be hidden by the animation.

The following is my code sample:

<Page.Resources>
        <Style x:Key="AppBarButtonStyle1" TargetType="AppBarButton">
            <Setter Property="Background" Value="{ThemeResource AppBarButtonBackground}"/>
            <Setter Property="Foreground" Value="{ThemeResource AppBarButtonForeground}"/>
            <Setter Property="BorderBrush" Value="{ThemeResource AppBarButtonBorderBrush}"/>
            <Setter Property="HorizontalAlignment" Value="Left"/>
            <Setter Property="VerticalAlignment" Value="Top"/>
            <Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}"/>
            <Setter Property="FontWeight" Value="Normal"/>
            <Setter Property="Width" Value="68"/>
            <Setter Property="UseSystemFocusVisuals" Value="True"/>
            <Setter Property="AllowFocusOnInteraction" Value="False"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="AppBarButton">
                        <Grid x:Name="Root" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" MaxWidth="{TemplateBinding MaxWidth}" MinWidth="{TemplateBinding MinWidth}">
                            <Grid.Resources>
                                <Style x:Name="LabelOnRightStyle" TargetType="AppBarButton">
                                    <Setter Property="Width" Value="NaN"/>
                                </Style>
                            </Grid.Resources>
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="ApplicationViewStates">
                                    <VisualState x:Name="FullSize"/>
                                    <VisualState x:Name="Compact">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="TextLabel">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="LabelOnRight">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Margin" Storyboard.TargetName="Content">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="12,14,0,14"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="MinHeight" Storyboard.TargetName="ContentRoot">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarThemeCompactHeight}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Grid.Row)" Storyboard.TargetName="TextLabel">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="0"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Grid.Column)" Storyboard.TargetName="TextLabel">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="1"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="TextAlignment" Storyboard.TargetName="TextLabel">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="Left"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Margin" Storyboard.TargetName="TextLabel">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="8,15,12,17"/>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="LabelCollapsed">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="MinHeight" Storyboard.TargetName="ContentRoot">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarThemeCompactHeight}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="TextLabel">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Overflow">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="ContentRoot">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="OverflowTextLabel">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="OverflowWithToggleButtons">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="ContentRoot">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="OverflowTextLabel">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Margin" Storyboard.TargetName="OverflowTextLabel">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="38,0,12,0"/>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal">
                                        <Storyboard>
                                            <PointerUpThemeAnimation Storyboard.TargetName="OverflowTextLabel"/>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="PointerOver">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="Root">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarButtonBackgroundPointerOver}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="Root">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarButtonBorderBrushPointerOver}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="Content">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarButtonForegroundPointerOver}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="TextLabel">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarButtonForegroundPointerOver}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="OverflowTextLabel">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarButtonForegroundPointerOver}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <PointerUpThemeAnimation Storyboard.TargetName="OverflowTextLabel"/>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Pressed">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="Root">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarButtonBackgroundPressed}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="Root">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarButtonBorderBrushPressed}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="Content">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarButtonForegroundPressed}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="TextLabel">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarButtonForegroundPressed}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="OverflowTextLabel">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarButtonForegroundPressed}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <PointerDownThemeAnimation Storyboard.TargetName="OverflowTextLabel"/>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="Root">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarButtonBackgroundDisabled}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="Root">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarButtonBorderBrushDisabled}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="Content">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarButtonForegroundDisabled}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="TextLabel">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarButtonForegroundDisabled}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="OverflowTextLabel">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarButtonForegroundDisabled}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="InputModeStates">
                                    <VisualState x:Name="InputModeDefault"/>
                                    <VisualState x:Name="TouchInputMode">
                                        <VisualState.Setters>
                                            <Setter Target="OverflowTextLabel.Padding" Value="0,11,0,13"/>
                                        </VisualState.Setters>
                                    </VisualState>
                                    <VisualState x:Name="GameControllerInputMode">
                                        <VisualState.Setters>
                                            <Setter Target="OverflowTextLabel.Padding" Value="0,11,0,13"/>
                                        </VisualState.Setters>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Grid x:Name="ContentRoot" MinHeight="{ThemeResource AppBarThemeMinHeight}">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                </Grid.RowDefinitions>
                                <ContentPresenter x:Name="Content" Visibility="Collapsed" AutomationProperties.AccessibilityView="Raw" Content="{TemplateBinding Icon}" Foreground="{TemplateBinding Foreground}" HorizontalAlignment="Stretch" Height="20" Margin="0,14,0,4"/>
                                <TextBlock x:Name="TextLabel" Foreground="{TemplateBinding Foreground}" FontSize="12" FontFamily="{TemplateBinding FontFamily}" Margin="2,0,2,6" Grid.Row="1" TextAlignment="Center" TextWrapping="Wrap" Text="{TemplateBinding Label}"/>
                            </Grid>
                            <TextBlock x:Name="OverflowTextLabel" Foreground="{TemplateBinding Foreground}" FontSize="15" FontFamily="{TemplateBinding FontFamily}" HorizontalAlignment="Stretch" Margin="12,0,12,0" Padding="0,5,0,7" TextAlignment="Left" TextWrapping="NoWrap" Text="{TemplateBinding Label}" TextTrimming="Clip" Visibility="Collapsed" VerticalAlignment="Center"/>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Page.Resources>

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    </Grid>
    <Page.BottomAppBar>
        <CommandBar IsOpen="True" IsSticky="True">
            <AppBarButton Label="lab1" Style="{StaticResource AppBarButtonStyle1}"></AppBarButton>
        </CommandBar>
    </Page.BottomAppBar>

Best Regards,

Xavier Eoro


这篇关于[UWP]如何在Uwp中删除/隐藏AppBarButton中的椭圆/虚线按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆