docs-maui icon indicating copy to clipboard operation
docs-maui copied to clipboard

Custom controls

Open davidbritch opened this issue 2 years ago • 0 comments

Create content about how to create custom controls in .NET MAUI. This should include writing IVisualElementTree overrides/wiring into the LogicalChildren APIs.

For a custom control whose size changes (e.g. a property change), in most situations the underlying platform's invalidation will kick in and trigger a measure/arrange pass if necessary. But not in all situations, and it can differ per platform. The advice is to see if a custom control works without calling InvalidateMeasure. If it doesn't, add a call in to InvalidateMeasure.

https://learn.microsoft.com/en-us/uwp/api/windows.ui.xaml.uielement.invalidatemeasure?view=winrt-22621#remarks is a good summary of the situation for MAUI, although MAUI is more complicated by having different platforms that have different rules for when they invalidate things.

https://github.com/dotnet/maui/issues/11106

davidbritch avatar Jan 27 '23 10:01 davidbritch