[WinUI] Cannot invalidate measure and arrange for a ContentView #17367
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
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.
Steps to Reproduce
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
The text was updated successfully, but these errors were encountered: