I want to make a simple board game for windows phone that has 5 x 5 square shaped tiles on it. Obviously I'd like it to have a dynamic interface where the tiles' width and height property are set according to the user's phone resolution. For that matter, in my XAML
code I have used the * thing to divide my page width into 5 columns(relative size) and in each column I have a stack panel to which I add 5 buttons. like this:
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<StackPanel x:Name="ButtonsCol0" Grid.Column="0">
<Button Background="AliceBlue"
MinWidth="{Binding ActualHeight, RelativeSource={RelativeSource Self}}"
MinHeight="{Binding ActualWidth, RelativeSource={RelativeSource Self}}">
</Button>
<Button
MinWidth="{Binding ActualHeight, RelativeSource={RelativeSource Self}}"
MinHeight="{Binding ActualWidth, RelativeSource={RelativeSource Self}}">
</Button>
<Button
MinWidth="{Binding ActualHeight, RelativeSource={RelativeSource Self}}"
MinHeight="{Binding ActualWidth, RelativeSource={RelativeSource Self}}">
</Button>
<Button
MinWidth="{Binding ActualHeight, RelativeSource={RelativeSource Self}}"
MinHeight="{Binding ActualWidth, RelativeSource={RelativeSource Self}}">
</Button>
<Button
MinWidth="{Binding ActualHeight, RelativeSource={RelativeSource Self}}"
MinHeight="{Binding ActualWidth, RelativeSource={RelativeSource Self}}">
</Button>
</StackPanel>
(I have 4 more of the StackPanel
above for each column)
Now the problem is that I want the tiles to have a square shape(same height and width), I found this question and that is why I added:
MinWidth="{Binding ActualHeight, RelativeSource={RelativeSource Self}}"
MinHeight="{Binding ActualWidth, RelativeSource={RelativeSource Self}}">
to my buttons, this seems to work but when I run the code, the result is like this:
please help... :)