public WinUINativeDrawingContext(IUIElement uiElement)
        {
            if (uiElement is not Microsoft.UI.Xaml.UIElement winUIUIElement)
            {
                throw new InvalidOperationException($"uiElement is of type {uiElement.GetType()}, not of expected type Microsoft.UI.Xaml.UIElement");
            }

            _compositor = ElementCompositionPreview.GetElementVisual(winUIUIElement).Compositor;
        }
 /// <summary>
 /// Returns a <see cref="Media.Rectangle"/> that represents the layout partition that is reserved for a child element<para></para>
 /// It is equivalent to the rectangle returned by the <see cref="IUIElement.RenderTarget"/> property, modified to include eventual padding values
 /// </summary>
 /// <param name="element">The <see cref="IUIElement"/> instance to compute the layout slot of</param>
 /// <returns>A <see cref="Media.Rectangle"/> that represents the layout partition that is reserved for a child element</returns>
 public static Media.Rectangle GetLayoutSlot(IUIElement element)
 {
     IPaddedElement paddedElement;
     Media.Point layoutSlotPosition;
     Media.Size layoutSlotSize;
     Media.Rectangle layoutSlot;
     layoutSlotPosition = element.RenderTarget.Position;
     layoutSlotSize = element.RenderTarget.Size;
     if (typeof(IPaddedElement).IsAssignableFrom(element.GetType()))
     {
         paddedElement = (IPaddedElement)element;
         layoutSlotPosition += new Media.Point(paddedElement.Padding.Left, paddedElement.Padding.Top);
         layoutSlotSize = new Media.Size(layoutSlotSize.Width - paddedElement.Padding.Left - paddedElement.Padding.Right, layoutSlotSize.Height - paddedElement.Padding.Top - paddedElement.Padding.Bottom );
     }
     layoutSlot = new Media.Rectangle(layoutSlotPosition, layoutSlotSize);
     return layoutSlot;
 }