[英]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.