【发布时间】:2013-02-24 06:12:57
【问题描述】:
我想从 C# 中的另一个类中绘制一个矩形 进入我的主窗口
<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>
这是我的类代码 sn-p,我试图在 mainWindow 中绘制一个矩形
private UIElement container;
private Rect rect1 = new Rect();
public TestPage(UIElement cont)
{
this.container = cont;
}
private void init()
{
this.container.Children.Add(rect1);
}
如何处理?
【问题讨论】: