Created UserControl and trying to load it on the main window. In the main window there is a StackPanel and a Grid, but wherever I try to add UC - the same error -
Argument 1: cannot convert from 'Performance.CPUUserControl' to 'System.Windows.UIElement'
Here is the code -
private void Window_Loaded(object sender, RoutedEventArgs e) { CPUUserControl cPUUser = new CPUUserControl(); UserControlGrid.Children.Add(cPUUser); StackPanelUserControl.Children.Add(cPUUser); //MainFrame.Navigate(cPUUser); } How to add UC to the window?
.Children.Addis not appropriate in WPF, you need to forget this and leave it in WinForms! - EvgeniyZ