maui icon indicating copy to clipboard operation
maui copied to clipboard

[Windows] Fix for setting IsClippedToBounds="True" inside a Border control will crash on Windows

Open Tamilarasan-Paranthaman opened this issue 4 months ago • 3 comments

Root cause of the issue :

  1. Attempting to set the clip, the layout process might not be complete for the content (VisualElement), which can cause an unhandled exception.

  2. When maximizing the window, the already applied clip causes the exception again.

Description of Change

  1. Adding await Task.Yield() asynchronously yields control back to the UI thread, allowing any pending layout passes to be completed.

After the layout is finalized, it sets the clip on the visual, ensuring that exceptions related to the visual tree being in an unstable state are avoided.

This ensures that:

  • The content control's visual tree is fully constructed.
  • The compositor and visual elements are ready to receive modifications.
  1. The clip is cleared before applying a new one, which resolves the exception when maximizing the window.

Issues Fixed

Fixes #18937

Screenshot

Before Issue Fix After Issue Fix

Tamilarasan-Paranthaman avatar Oct 24 '24 15:10 Tamilarasan-Paranthaman