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

SizeChanged event fires when size hasn't changed #27223

Closed
MitchBomcanhao opened this issue Jan 20, 2025 · 3 comments · Fixed by #27476
Closed

SizeChanged event fires when size hasn't changed #27223

MitchBomcanhao opened this issue Jan 20, 2025 · 3 comments · Fixed by #27476
Labels
partner/syncfusion Issues / PR's with Syncfusion collaboration platform/windows 🪟 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working

Comments

@MitchBomcanhao
Copy link

MitchBomcanhao commented Jan 20, 2025

Description

I'm not entirely sure if this is a bug or not, but it feels like one, and I'd like your opinion on it.

I'm getting SizeChanged events firing for a UI element that is not being modified - its position on screen is changing as the layout recalculates itself when I resize the window, but the height/width of the element should otherwise be unchanged. when looking at the values, they appear unchanged. briefly looking into maui code (although I could be looking in the wrong place), it seems that this event may be fired when the bounding rectangle changes in some way, which includes its originating coordinates, besides the width and height.

example consecutive events firing when resizing the window vertically:

  • SizeChanged {X=0 Y=614.4000244140625 Width=700 Height=70.4000015258789}
  • SizeChanged {X=0 Y=636 Width=700 Height=70.4000015258789}

what should be happening, then?

Steps to Reproduce

  • Create a blank maui project.
  • replace the mainpage content with the one below
  • replace the relevant c# code with the one below
  • run the app and resize the window vertically
  • OBSERVE
    • the VerticalStackLayout_SizeChanged method will keep firing even though the actual size of the VerticalStackLayout hasn't changed.
    <Grid ColumnDefinitions="*,*,*">
        <Grid Grid.Column="0" RowDefinitions="Auto,*,Auto">
            <Label x:Name="Counter" Grid.Row="0" />
            <VerticalStackLayout Grid.Row="2" SizeChanged="VerticalStackLayout_SizeChanged">
                <Button Text="button 1" />
                <Button Text="button 2" />
                <Button Text="button 3" />
            </VerticalStackLayout>
        </Grid>
        <Editor x:Name="ShowSizes"
                Grid.Column="1"
                BackgroundColor="DarkBlue"
                VerticalOptions="Fill" />
        <Editor x:Name="ShowCoordinates"
                Grid.Column="2"
                BackgroundColor="DarkGoldenrod"
                VerticalOptions="Fill" />
    </Grid>
        int counter = 0;
        private void VerticalStackLayout_SizeChanged(object sender, EventArgs e)
        {
            if (sender is VerticalStackLayout ctrl)
            {
                counter++;
                this.Counter.Text = $"resized {counter} times";
                this.ShowSizes.Text = $"Width:{ctrl.Width:G17} Height:{ctrl.Height:G17}\n" + this.ShowSizes.Text;
                this.ShowCoordinates.Text = $"X:{ctrl.X} Y:{ctrl.Y} \n" + this.ShowCoordinates.Text;
            }
        }

Image

Link to public reproduction project repository

No response

Version with bug

9.0.30 SR3

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Windows, I was not able test on other platforms

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

@MitchBomcanhao MitchBomcanhao added the t/bug Something isn't working label Jan 20, 2025
@Ying-6
Copy link

Ying-6 commented Jan 22, 2025

Hi @MitchBomcanhao, sorry, could you provide a simple reproduction project for us to investigate it further? Looking forward to your reply!

@MitchBomcanhao
Copy link
Author

@Ying-6 I've provided some basic xaml and c# to see this in action. most of it is unnecessary and only for the purposes of showcasing the dimensions values, all you actually need is the grid with the vertical stacklayout and its basic sizeChanged event.

@Ying-6 Ying-6 added s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage labels Jan 24, 2025
@Ying-6
Copy link

Ying-6 commented Jan 24, 2025

This issue has been verified using Visual Studio 17.13 Preview 3.0 (9.0.30 & 9.0.22 & 9.0.0). Can repro this issue on Windows platform.
MauiApp3.zip

@karthikraja-arumugam karthikraja-arumugam added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Jan 30, 2025
@jsuarezruiz jsuarezruiz added this to the .NET 9 Servicing milestone Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
partner/syncfusion Issues / PR's with Syncfusion collaboration platform/windows 🪟 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants