I want to draw a rect from another class in c# into my mainWindow
<Window x:Class="MyApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Name="mainWindow" Height="768" Width="1366" >
</Window>
Here is my Class code snippet which I tried to draw a rect to mainWindow
private UIElement container;
private Rect rect1 = new Rect();
public TestPage(UIElement cont)
{
this.container = cont;
}
private void init()
{
this.container.Children.Add(rect1);
}
How to handle it?