XAML AppBarButton Bottom Border disapears by changing the AppBarButton height under 40

Florian M 1 Reputation point
2021-06-16T19:55:16.397+00:00

You know why the border bottom disapears by changing the height under 40 ?

Where in the Style can i change the values of the border?

106297-borderproblem.png

Universal Windows Platform (UWP)
{count} votes

1 answer

Sort by: Most helpful
  1. AryaDing-MSFT 2,916 Reputation points
    2021-06-18T07:05:38.663+00:00

    Hi,

    Welcome to Microsoft Q&A!

    When you use AppBarButton, it use the default style whose key is AppBarButtonRevealStyle. As follows:

    <Style TargetType="AppBarButton" x:Key="AppBarButtonRevealStyle">  
    …  
                               <Viewbox x:Name="ContentViewbox"  
                                    Height="{ThemeResource AppBarButtonContentHeight}"  
                                    Margin="{ThemeResource AppBarButtonContentViewboxCollapsedMargin}"  
                                    HorizontalAlignment="Stretch"  
                                    AutomationProperties.AccessibilityView="Raw" >  
                                    <ContentPresenter x:Name="Content"  
                                        Content="{TemplateBinding Icon}"  
                                        Foreground="{TemplateBinding Foreground}"/>  
                                </Viewbox>  
                                <TextBlock x:Name="TextLabel"  
                                    Grid.Row="1"  
                                    Text="{TemplateBinding Label}"  
                                    Foreground="{TemplateBinding Foreground}"  
                                    FontSize="12"  
                                    FontFamily="{TemplateBinding FontFamily}"  
                                    TextAlignment="Center"  
                                    TextWrapping="Wrap"  
                                    Margin="{ThemeResource AppBarButtonTextLabelMargin}"  
                                    AutomationProperties.AccessibilityView="Raw" />  
     ……  
      
            
    </Style>  
    

    As you can see, the AppBarButton consists of Viewbox and TextBlock, the viewBox contains an icon, the icon has a fixed size, its height is AppBarButtonContentHeight whose value is 16, its margin is AppBarButtonContentViewboxCollapsedMargin whose value is “0,12,0,4”. Therefore, if you want to see the entired icon, you cannot set its height to be less than 28(viewbox.Height+margin.Top). Besides, the container of AppbarButton is Commandbar, the MinHeight of Commandbar is AppBarThemeCompactHeight whose value is 40, so you need to set AppBarButton.Height to be greater than 40, otherwise, the border bottom will disappear.


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.