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?
一个窗口只能有一个内容,因此您必须设置窗口的Content
属性。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.