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

[WinUI] Cannot invalidate measure and arrange for a ContentView #17367

Open
marchev-prgs opened this issue Sep 14, 2023 · 3 comments
Open

[WinUI] Cannot invalidate measure and arrange for a ContentView #17367

marchev-prgs opened this issue Sep 14, 2023 · 3 comments
Labels
area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter partner Issue or Request from a partner team platform/windows 🪟 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@marchev-prgs
Copy link

Description

Please see project in repo. I have a custom class that inherits from ContentView, called CustomContentView. I have a Max property in it, and when the property changes, some custom logic should kick in that will eventually affect the desired size of the custom view, and so it should get re-arranged. This is why I invoke InvalidateMeasure() in the Max property changed. However nothing happens after that, the content view is not invalidated and there is no MeasureOverride and ArrangeOverride after.

custom_content_view_invalidate

Steps to Reproduce

  1. Download the repo from the link (https://github.com/telerik/ms-samples/tree/main/Maui/CannotInvalidateContentViewInWinUI)
  2. Go to the Maui/CannotInvalidateContentViewInWinUI folder
  3. Run the app in WinUI
  4. Clear the Output window
  5. Click the "change max" button

Expected Behavior:
The measure and arrange of the custom content view should be invalidated and the MeasureOverride and ArrangeOverride methods should get invoked, so we should see information about this in the Output window.

Actual Behavior:
Nothing happens, MeasureOverride and ArrangeOverride are not invoked. The only thing in the output is the notification for the Max property change:
"::: CustomContentView OnMaxChanged"

Link to public reproduction project repository

https://github.com/telerik/ms-samples/tree/main/Maui/CannotInvalidateContentViewInWinUI

Version with bug

8.0.0-preview.7.8842

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

No response

Did you find any workaround?

@PureWeen suggested to use
(this.Parent as IView)?.InvalidateMeasure();
(this.Parent as IView)?.InvalidateArrange();

This helps a lot and effectively causes MeasureOverride and ArrangeOverride, but I suspect it has some limitations, for example when the custom view is in the ControlTemplate of another ContentView, and perhaps when native embedding is used and the custom view doesn't have a Parent.

Relevant log output

No response

@marchev-prgs marchev-prgs added the t/bug Something isn't working label Sep 14, 2023
@marchev-prgs
Copy link
Author

May be related to this issue: #7613

@jsuarezruiz jsuarezruiz added area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter partner Issue or Request from a partner team labels Sep 14, 2023
@XamlTest XamlTest added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Sep 15, 2023
@XamlTest
Copy link

Verified this on Visual Studio Enterprise 17.8.0 Preview 2.0. Repro on Windows 11(8.0.0-rc.1), not repro on Android 13.0-API33 and iOS 16.4 with below Project:
17367.zip

@jsuarezruiz jsuarezruiz added this to the Backlog milestone Sep 25, 2023
@ghost
Copy link

ghost commented Sep 25, 2023

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter partner Issue or Request from a partner team 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

No branches or pull requests

4 participants