Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grid ColumnSpacing and RowSpacing lost #9367

Open
HO-COOH opened this issue Feb 27, 2024 · 1 comment
Open

Grid ColumnSpacing and RowSpacing lost #9367

HO-COOH opened this issue Feb 27, 2024 · 1 comment
Labels
area-Layouts bug Something isn't working team-Controls Issue for the Controls team

Comments

@HO-COOH
Copy link

HO-COOH commented Feb 27, 2024

Describe the bug

I have 2 VisualState that changes a button's content to a Row/Column devided Grid, that has Grid.RowSpacing and Grid.ColumnSpacing applied. But it seems to be lost after toggling the VisualState back to the exact same state prior.

Steps to reproduce the bug

Create a new Page, use this xaml

<Page...>
    <Page.Resources>
        <Style TargetType="Rectangle">
            <Setter Property="Fill" Value="Red"/>
        </Style>
    </Page.Resources>
    <Grid>
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup>
                <VisualState x:Name="RowDevide">
                    <VisualState.Setters>
                        <Setter Target="PreviewButton.Content">
                            <Setter.Value>
                                <Grid ColumnSpacing="5" RowSpacing="5" Background="Green">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="50"/>
                                        <RowDefinition Height="50"/>
                                    </Grid.RowDefinitions>

                                    <Rectangle/>
                                    <Rectangle Grid.Row="1"/>
                                </Grid>
                            </Setter.Value>
                        </Setter>
                    </VisualState.Setters>
                </VisualState>

                <VisualState x:Name="ColumnDevide">
                    <VisualState.Setters>
                        <Setter Target="PreviewButton.Content">
                            <Setter.Value>
                                <Grid ColumnSpacing="5" RowSpacing="5" Background="Yellow">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="50"/>
                                        <ColumnDefinition Width="50"/>
                                    </Grid.ColumnDefinitions>

                                    <Rectangle/>
                                    <Rectangle Grid.Column="1"/>
                                </Grid>
                            </Setter.Value>
                        </Setter>
                    </VisualState.Setters>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>

        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>


        <Grid ColumnSpacing="20">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <Button Grid.Column="1" x:Name="PreviewButton" Width="500" Height="500" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"/>

            <StackPanel>
                <RadioButton HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Click="RadioButton_Click">Row</RadioButton>
                <RadioButton HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Click="RadioButton_Click_1">Col</RadioButton>
            </StackPanel>
        </Grid>
    </Grid>
</Page>

Use this code

        private void RadioButton_Click(object sender, RoutedEventArgs e)
        {
            VisualStateManager.GoToState(this, "RowDevide", false);
        }

        private void RadioButton_Click_1(object sender, RoutedEventArgs e)
        {
            VisualStateManager.GoToState(this, "ColumnDevide", false);
        }

Happens to both UWP & WinUI3 projects.

Expected behavior

No response

Screenshots

2024-02-28.00-29-20.mp4

NuGet package version

WinUI 3 - Windows App SDK 1.4.5: 1.4.240411001

Windows version

Windows 10 (1809): Build 17763

Additional context

No response

@HO-COOH HO-COOH added the bug Something isn't working label Feb 27, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Feb 27, 2024
@JesseCol JesseCol added area-Layouts team-Controls Issue for the Controls team and removed needs-triage Issue needs to be triaged by the area owners labels Feb 27, 2024
@ranjeshj
Copy link
Contributor

Weird. The traditional way to do something like this would be to have both Grid's in the tree and collapse/expand from the visual state manager. I'd expect what you are doing to work, but not sure what is going on with those properties.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Layouts bug Something isn't working team-Controls Issue for the Controls team
Projects
None yet
Development

No branches or pull requests

3 participants