I am building a program with WinUI 3 and would like to hide the controls behind a transparent panel, like ContentDialog do, while the content is loaded.
I tried to find the source code of the ContentDialog to get an inspiration but can't find it. The disassembly only show the abstraction to, what I suppose, is the WinRT control.
I tried to edit the template, like we did in the plain old WPF period, but the is no option to do it.
I found a web site who do it by placing a stretched canvas in front of the controls by modifyind the ZIndex, but can't find this property for either a Grid or a Canvas.
So, the question is in multiple parts, but the main goal is the same as the subject. The questions would be :
- Is there a way to change the Z-Index?
- Is there a way to edit the ContentDialog themplate?
- Is the WinRT version of the ContentDialog source code available somewhere?
Thanks.
Found a way. The solution is by setting the Canvas' (or possibly a Border or other controls) XamlRoot to the Window XamlRoot in the code behind. For example for a Canvas named 'Kanvas' with a K.:
The Xaml would look something like this :
I only tried what was needed for the ContentDialog. I tried to find why this does that but the only link I found provides a minimum of information. The official description by Microsoft is
So, I can only deduce the Xaml root of the main window show the original content and the canvas... And I thought a UIElement can only have one content...
Now, let's see how to do this in MVVM without code-behind...