Page 1 of 1

Trouble getting relative grid cell cell sizes

Posted: Tue Aug 30, 2016 12:20 pm
by SchnauzerDad
I am having trouble getting grid cells to have the relative sizes I expect. I am sure it is just me doing something dumb but I can't seem to figure it out.

If I make a grid with two rows and two columns all set to "1*" I would expect that the result would be 4 equal sized cells (and in fact that is exactly what the designer shows).

Here is my code:

Code: Select all

<Page
    x:Class="CSHTML_9_1_Test.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:CSHTML_9_1_Test"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">
    <Grid x:Name="mainGrid">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="1*" />
            <ColumnDefinition Width="1*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="1*" />
            <RowDefinition Height="1*" />
        </Grid.RowDefinitions>
        <StackPanel Grid.Column="0" Grid.Row="0" Background="Yellow">
            <TextBlock Text="Location 0,0" Padding="15,15,15,15"/>
        </StackPanel>
        <StackPanel Grid.Column="1" Grid.Row="0" Background="LightGreen">
            <TextBlock Text="Location 1,0" Padding="15,15,15,15"/>
        </StackPanel>
        <StackPanel Grid.Column="0" Grid.Row="1" Background="LightBlue">
            <TextBlock Text="Location 0,1" Padding="15,15,15,15"/>
        </StackPanel>
        <StackPanel Grid.Column="1" Grid.Row="1" Background="Pink">
            <TextBlock Text="Location 1,1" Padding="15,15,15,15"/>
        </StackPanel>
    </Grid>
</Page>


I expect this:

Expected.PNG
Expected.PNG (5.16 KiB) Viewed 6354 times


But when I run it I get this:

Actual.PNG
Actual.PNG (27.64 KiB) Viewed 6354 times


Can anyone tell me what I am doing wrong?

Thanks

Re: Trouble getting relative grid cell cell sizes

Posted: Fri Sep 02, 2016 11:42 am
by SchnauzerDad
I have tried everything I can think of and (a) this definitely not right compared to UWP and WPF behavior of the same code and (b) I just can't find any way to make it work as expected. Any help or comment from support?

Re: Trouble getting relative grid cell cell sizes

Posted: Sat Sep 03, 2016 12:00 am
by JS-Support @Userware
Hi,

Unfortunately this is a known issue that is due to the current "pure html" (no js) implementation of the Grid. Sorry for the inconvenience.

We plan to reengineer the Grid control in the coming months.

In the meantime, you may need to set some fixed sizes or use "auto", or put other controls inside the cells. If you would like to achieve the exact same result, you can attach to the SizeChanged event that is coming in Beta 9.2 (in just a few days) and set the position and sizes programmatically (in a canvas for example) based on the value of ActualWidth / 2 and ActualHeight / 2.

Thanks.
Regards
JS-Support

Re: Trouble getting relative grid cell cell sizes [solved]

Posted: Sun Sep 04, 2016 10:40 am
by SchnauzerDad
Just tried it with the new SizeChanged event in 9.2 and works fine.

Thank you