Is there a way to add a custom control to a WPF window created in code? I cannot find the Children property in the window class. In xaml, it will look like this:
<Window x:Class="MyWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:MyUserControls="clr-namespace:MyUserControls" Title="" Height="Auto" Width="550" ResizeMode="NoResize"> <MyUserControls:UC1 x:Name="uc1" /> </Window>
In the code, I tried something like this:
Window myWindow = new Window; UC1 uc1 = new UC1; myWindow.Children.Add(UC1);
thanks for the help
wpf user-controls
Basti
source share