Add new event to Layout.cs -> ChildMeasureInvalidated(object sender, EventArgs e)

RyanDixonRyanDixon USMember ✭✭✭
edited August 24 in Xamarin.Forms Evolution

Summary

At the moment, you can only detect when the layout's measure is invalidated. With this change, it will expose an additional event giving us the child which caused the invalidation to process up the stack.

API Changes

One new event will be exposed on Layout.cs called ChildMeasureInvalidated.
Layout.cs -> under line # 194 https://github.com/xamarin/Xamarin.Forms/blob/54322b98b4f7d43026ca51c813cc1fe320d153a8/Xamarin.Forms.Core/Layout.cs

Intended Use Case

Gives the end user more control over the layout, allowing them to know exactly what children are invalidated and when. This could be used to enhance caching in custom layouts further improving the performance of such layouts.

Notes

Edit: Another alternative would be to expose the sender as an optional parameter onto the virtual method if this removes the need for events!

I might be hugely wrong on this, and it would be cool to get other peoples thoughts as its a tiny change!
The idea came along as I have my own "InfiniteLayout" which loads views in when scrolling and loops over itself, and currently I can only invalidate all the SizeMeasures at once.
I don't mind adding this myself in a PR!

:smile:

0
0 votes

Open · Last Updated

Sign In or Register to comment.