[英]Add Rect from another class in c#
我想从C#中的另一个类到我的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>
这是我的Class代码段,我尝试将其绘制为mainWindow
private UIElement container;
private Rect rect1 = new Rect();
public TestPage(UIElement cont)
{
this.container = cont;
}
private void init()
{
this.container.Children.Add(rect1);
}
如何处理?
一个窗口只能有一个内容,因此您必须设置窗口的Content
属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.