Rui Huang
Rui Huang

Reputation: 382

How to Customize Button's Size?

I have problem to customize the buttons' size in my stack panel. I made one experiment with Rectangle, it looks perfect, here is the code in the XAML:

 <StackPanel Orientation="Horizontal" VerticalAlignment="Top">
    <Rectangle Width="170" Height="170" Fill="Bisque" Margin="10,0,0,0" />
    <StackPanel Orientation="Vertical" Margin="10,0,0,0">
        <StackPanel Orientation="Horizontal">
            <Rectangle Width="80" Height="80" Fill="Azure" />
            <Rectangle Width="80" Height="80" Fill="Azure" Margin="10,0,0,0" />
        </StackPanel>
                        
        <StackPanel Orientation="Horizontal" Margin="0,10,0,0">
            <Rectangle Width="80" Height="80" Fill="Tomato" />
            <Rectangle Width="80" Height="80" Fill="Azure" Margin="10,0,0,0" />
        </StackPanel>
    </StackPanel>
                    
</StackPanel>

Here is the screen shot:

enter image description here

But, when I remove those Rectangles to Buttons, like these in the XAML:

<Button x:Name="Btn2" >
</Button>
<Button x:Name="Btn3" Width="40" Height="40" Margin="11,0,0,0"  >
</Button>

it looks not what i want:

enter image description here

I can't resize those 2 buttons. How to get a quick solution for this?

Upvotes: 0

Views: 49

Answers (1)

Romasz
Romasz

Reputation: 29792

Buttons in WP8.1 have deafault minimum width - MinWidth property - try changing it and it should help.

A side note - consider using Grid panel instead of StackPanel for positioning elements. If you define some Rows and Columns, your app should scale correctly when used on different devices.

Upvotes: 1

Related Questions