는 여기에 다음 줄을 주석 경우에만 그립니다 나는 다음과 같은 방법WPF에서는 어떻게 WindowsFormsHost에 선을 그릴 수 있습니까?
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;
}
라인을 실행 형태의 부하에 내 XAML
<Grid
Name="grid">
<TextBlock
Text="Some Label" />
<WindowsFormsHost
Name="winFormsHost">
</WindowsFormsHost>
</Grid>
입니다.
this.winFormsHost.Child = oldSchoolTextbox;
어떻게 WindowsFormsHost 컨트롤 위에 선을 그립니 까?
조금 해킹되지만 작동합니다. 감사합니다! –
이 경로를 사용하면 대부분의 경우 강제로 창 위치에 동기화됩니다. onDrag onResize 등을 조작하십시오. – Li3ro