这是我的XAML在WPF中,你如何在WindowsFormsHost上绘制一条线?
<Grid
Name="grid">
<TextBlock
Text="Some Label" />
<WindowsFormsHost
Name="winFormsHost">
</WindowsFormsHost>
</Grid>
在我执行下面的方法
protected void OnLoad(object sender, RoutedEventArgs e)
{
// Create a line on the fly
Line line = new Line();
line.Stroke = Brushes.Red;
line.StrokeThickness = 17;
line.X1 = 50;
line.Y1 = 50;
line.X2 = 250;
line.Y2 = 50;
this.grid.Children.Add(line);
System.Windows.Forms.TextBox oldSchoolTextbox = new System.Windows.Forms.TextBox();
oldSchoolTextbox.Text = "A bunch of Random Text will follow. ";
oldSchoolTextbox.WordWrap = true;
oldSchoolTextbox.Width = 300;
for (int i = 0; i < 250; i++)
{
oldSchoolTextbox.Text += "abc ";
if (i % 10 == 0)
{
oldSchoolTextbox.Text += Environment.NewLine;
}
}
this.winFormsHost.Child = oldSchoolTextbox;
}
线形式的负载,当我注释掉以下行只平。
this.winFormsHost.Child = oldSchoolTextbox;
如何在WindowsFormsHost控件上绘制一条线?
这是一个小黑客,但它会工作。非常感谢! – 2009-06-17 16:04:04