Hello anonymous user,
Elements invalidate themselves by invoking the InvalidateMeasure
method, generally when a property of the element changes that might result in a new size of the element. The Layout class also defines an InvalidateLayout
method that has a similar purpose to the InvalidateMeasure
method. The InvalidateLayout
method should be invoked whenever a change is made that affects how the layout positions and sizes its children.
You could refer to the Invalidation part of this article at https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/layouts/custom#invalidation and this article at https://learn.microsoft.com/en-us/xamarin/xamarin-forms/creating-mobile-apps-xamarin-forms/summaries/chapter26#some-rules-for-coding-layouts
About sample, you could check https://learn.microsoft.com/en-us/samples/xamarin/xamarin-forms-samples/userinterface-customlayout-wraplayout
Best Regards,
Wenyan Zhang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.