Why is there always a 10px add-on in System.Windows.Controls.Button?

See screenshot. The blue bounding box is the button, and the blue fill is the box. I can’t understand for my whole life how to get rid of the gasket in the button. Is there a way to place a rectangle in the upper left corner so that it touches the blue border?

alt text

Thank.

+3
source share
3 answers

Have you tried setting the marker Rectangleon 0?

<Button x:Name="Button" BorderThickness="0" Margin="0" Padding="0" Width="96" Height="96">
    <Rectangle Fill="Blue" Margin="0" Width="96" Height="96" />
</Button>

EDIT . Indents should come from a button control pattern. Try using a custom template:

<Style x:Key="MyButton" TargetType="Button">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="Button">
                <Grid>
                    <Rectangle Fill="Blue" Margin="0" Width="96" Height="96" />
                </Grid>
           </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

<Button x:Name="Button" BorderThickness="0" Margin="0" Padding="0"
    Width="96" Height="96" Style="{StaticResource MyButton}" />
+7
source

:

onclick .

+1

, , Windows Phone?

, , , , , Padding, "PhoneTouchTargetOverhang". Thickness, App.xaml "PhoneButtonBase" Margin .

, Windows Phone 7 . , , "PhoneButtonBase", "PhoneTouchTargetOverhang". , .

0

Source: https://habr.com/ru/post/1770042/


All Articles