I'm trying to create a custom xaml control in WinUI3 and found the Microsoft.UI.Xaml.Hosting.ElementCompositionPreview has some method to manipulate the visual composition tree, but I need the element to be a mix of elements in the ControlTemplate and some visual elements added by the custom control.
So far I was able to get the visual of the control by using
var visual = Microsoft.UI.Xaml.Hosting.ElementCompositionPreview.GetElementVisual(this);
And I could create the visual I need to insert, but it always appear in front of the ControlTemplate elements
I tried using
Microsoft.UI.Xaml.Hosting.ElementCompositionPreview.SetElementChildVisual(this, _drawingVisual);
and
visual.Children.InsertAtBottom(_drawingVisual);
And both are presented on top of the control template. I need them at the background