maui
maui copied to clipboard
InvalidateMeasure() does not trigger a native layout.
Description
If you call label.Handler.NativeView.InvalidateMeasure(label) it doesnt trigger a layout.
This is problematic, as we need to trigger re-layouts when font sizes change.
Steps to Reproduce
I am using comet, My View Heirarchy is
VStack{ Text(), Button() }
When I set the text to exact sizing, it matches the initial value. If on button click, I extend the labels text to more characters, it doesn't relayout.
I also added
LabelHandler.LabelMapper.Add(nameof(IText.Text), (h, l) => {
h.NativeView.InvalidateMeasure(l);
LabelHandler.MapText(h, l);
});
to force the invalidate
Version with bug
Preview 11
Last version that worked well
Unknown/Other
Affected platforms
iOS, Android, macOS
Affected platform versions
All
Did you find any workaround?
No response
Relevant log output
No response
Thank you so much for your bug report! Unfortunately, we cannot reproduce your issue with the information above, could you provide a sample project and screenshots or more details that we can reproduce your issue? That should greatly speed up the process, thanks!
Hi @Clancey. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
I'm also running into this in various areas when doing anything dynamic
I got a feeling you are supposed to use some new method from IView or something... @hartez is that still something as I see a explicit implementation or did that all change?
Will calling InvalidateMeasure() trigger the UnLoaded event? I write a sample project MauiApp4102.zip.
Please add breakpoint in UnLoadedEvent and run the project. Then click the "Change Font Size" button.
I validated with vs main build(32507.29.main) and the UnLoaded event wasn't triggered.
Hi @Clancey. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
Will calling
InvalidateMeasure()trigger theUnLoadedevent?
No. InvalidateMeasure should cause the UI to be layout it's views.
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.
Try InvalidateMeasureNonVirtual(InvalidationTrigger.HorizontalOptionsChanged); this will cause the parent view to layout and call your MeasureOverride and ArrangeOverride. Do not forget to set manually DesiredSize inside your MeasureOverride in case you do not call its base.
Repro on version 17.6.0 Preview 3.0 with the above project MauiApp4102.zip. It doesn't cause the UI to be layout it's views.