user3821206
user3821206

Reputation: 619

Image filling a button UWP Xaml

I am having problem in stretching my image to fill the button,I am new in UWP this is my code:

 <Grid  Margin="0,0,0,54" VerticalAlignment="Bottom" Height="39" Style="{Binding HorizontalAlignment, ElementName=grid}" ScrollViewer.HorizontalScrollBarVisibility="Auto">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <Button Grid.Column="0"  Height="39" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
            <Image Source="images/icon1.png" Stretch="Fill" RenderTransformOrigin="0.5,0.5" UseLayoutRounding="True" d:LayoutRounding="Auto" />

        </Button>
        <Button Grid.Column="1"  Height="39" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
            <Image Source="images/icon2.png" Stretch="Fill" RenderTransformOrigin="0.5,0.5" UseLayoutRounding="True" d:LayoutRounding="Auto" />
        </Button>

</Grid>

Upvotes: 9

Views: 16975

Answers (1)

You probably need to change the Padding and BorderThickness properties of the button. As code below :

    <Button Grid.Column="0" Height="39" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Padding="0" BorderThickness="0">
        <Image Source="Assets/microsoft.png" Stretch="UniformToFill"/>
    </Button>

Upvotes: 22

Related Questions