Reputation: 79
In my code:
<Grid x:Name="LayoutRoot" Background="Black">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid Name="Panel" Grid.Row="0" Grid.Column="0" Height="100" Width="*" HorizontalAlignment="Left" VerticalAlignment="Top">
</Grid>
</Grid>
I want the inner grid to fill the whole width of the screen. so I thought putting a *
will do that. but it says it is not in a correct format.
How can I set the inner grid to fill the width?
Upvotes: 0
Views: 135
Reputation: 7409
Width
property is of type double
and doesn't accept a value of type GridLength
. Therefore you will get an exception saying "'*' string cannot be converted to Length."
Also you should not set HorizontalAlignment="Left"
. If you wish to stretch the Width of control set it as HorizontalAlignment="Stretch"
.
If you set HorizontalAlignment="Left"
then elements are aligned to the left of the parent element's allocated layout space.
You can get more useful info at here. I would suggest to go over it so you can get more idea, how to place/arrange control in a better way on UI.
<Grid Name="Panel" Grid.Row="0" Grid.Column="0" Height="100" HorizontalAlignment="Stretch" VerticalAlignment="Top" />
Upvotes: 1
Reputation: 9242
just set the HorizontalAlignment property of the grid to stretch like this..and remove the width property..
<Grid Name="Panel" Grid.Row="0" Grid.Column="0" Height="100" HorizontalAlignment="Stretch" VerticalAlignment="Top">
</Grid>
hope it will solve your problem..
Upvotes: 0