直接上代码
方案一:
Code
private void Window_Loaded(object sender, RoutedEventArgs e)
{
System.Windows.Forms.Button btn = new System.Windows.Forms.Button();
btn.Width = 800; btn.Height = 600;
System.Windows.Forms.Panel panel = new System.Windows.Forms.Panel();
panel.AutoScroll = true; panel.AutoSize = true;
WindowsFormsHost winFormHost = new WindowsFormsHost();
winFormHost.Child = panel;
panel.Controls.Add(btn);
this.mydock.Content = winFormHost;
ElementHost elemHost = new ElementHost();
elemHost.AutoSize = true;
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
System.Windows.Forms.Button btn = new System.Windows.Forms.Button();
btn.Width = 800; btn.Height = 600;
System.Windows.Forms.Panel panel = new System.Windows.Forms.Panel();
panel.AutoScroll = true; panel.AutoSize = true;
WindowsFormsHost winFormHost = new WindowsFormsHost();
winFormHost.Child = panel;
panel.Controls.Add(btn);
this.mydock.Content = winFormHost;
ElementHost elemHost = new ElementHost();
elemHost.AutoSize = true;
}
方案二:
Code
<Canvs Title="File6.cml" x:Name="mydock">
<WindowsFormsHost>
<winform:Panel AutoScroll="True" AutoSize="True" x:Name="scrollPanel">
</winform:Panel>
</WindowsFormsHost>
</Canvs >
<Canvs Title="File6.cml" x:Name="mydock">
<WindowsFormsHost>
<winform:Panel AutoScroll="True" AutoSize="True" x:Name="scrollPanel">
</winform:Panel>
</WindowsFormsHost>
</Canvs >
Code
private void Window_Loaded(object sender, RoutedEventArgs e)
{
System.Windows.Forms.Button btn = new System.Windows.Forms.Button();
btn.Width = 800; btn.Height = 600;
scrollPanel.Controls.Add(btn);
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
System.Windows.Forms.Button btn = new System.Windows.Forms.Button();
btn.Width = 800; btn.Height = 600;
scrollPanel.Controls.Add(btn);
}
更多参考http://fallingsun007.spaces.live.com/blog/cns!C1786539A5DA05CB!122.entry