WPF项目如何调用winform项目中的自定义控件

u011128440 2013-09-10 10:53:13
一个WPF项目、一个Winform下的写的usercontrol,想在WPF项目中调用此usercontrol,请问如何引用并且添加到WPF窗体上?
...全文
347 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
u011128440 2013-09-11
  • 打赏
  • 举报
回复
引用 6 楼 lh520cq 的回复:
[quote=引用 4 楼 u011128440 的回复:] [quote=引用 2 楼 lh520cq 的回复:] Geomam.UserControl1 xx = new Geomam.UserControl1(); System.Windows.Forms.Integration.WindowsFormsHost host = new System.Windows.Forms.Integration.WindowsFormsHost(); host.Child = xx; this.MStackPanel.Children.Add(host);
就这些么? 不需要引用什么之类的么[/quote] 1.引用 WindowsFormsIntegration.dll 2.MStackPanel是Grid的Name------------<Grid Name="MStackPanel" /> 3.Geomam.UserControl1 xx = new Geomam.UserControl1();这里你用你自己的控件 [/quote] 我用WPF应用程序可以调用成功 但是用WPF浏览器就不行,总是报错,无可用源。 这是什么原因呢。 WPF浏览器怎么调用控件额
lh520cq 2013-09-10
  • 打赏
  • 举报
回复
引用 4 楼 u011128440 的回复:
[quote=引用 2 楼 lh520cq 的回复:] Geomam.UserControl1 xx = new Geomam.UserControl1(); System.Windows.Forms.Integration.WindowsFormsHost host = new System.Windows.Forms.Integration.WindowsFormsHost(); host.Child = xx; this.MStackPanel.Children.Add(host);
就这些么? 不需要引用什么之类的么[/quote] 1.引用 WindowsFormsIntegration.dll 2.MStackPanel是Grid的Name------------<Grid Name="MStackPanel" /> 3.Geomam.UserControl1 xx = new Geomam.UserControl1();这里你用你自己的控件
u011128440 2013-09-10
  • 打赏
  • 举报
回复
引用 3 楼 rui_china 的回复:
[quote=引用 2 楼 lh520cq 的回复:] Geomam.UserControl1 xx = new Geomam.UserControl1(); System.Windows.Forms.Integration.WindowsFormsHost host = new System.Windows.Forms.Integration.WindowsFormsHost(); host.Child = xx; this.MStackPanel.Children.Add(host);
自己可以写一个加载winfrom的用户控件[/quote] 能在说的详细点么。 MStackPanel这个是什么意思啊。我很菜
u011128440 2013-09-10
  • 打赏
  • 举报
回复
引用 2 楼 lh520cq 的回复:
Geomam.UserControl1 xx = new Geomam.UserControl1(); System.Windows.Forms.Integration.WindowsFormsHost host = new System.Windows.Forms.Integration.WindowsFormsHost(); host.Child = xx; this.MStackPanel.Children.Add(host);
就这些么? 不需要引用什么之类的么
灬浪子灬 2013-09-10
  • 打赏
  • 举报
回复
引用 2 楼 lh520cq 的回复:
Geomam.UserControl1 xx = new Geomam.UserControl1(); System.Windows.Forms.Integration.WindowsFormsHost host = new System.Windows.Forms.Integration.WindowsFormsHost(); host.Child = xx; this.MStackPanel.Children.Add(host);
自己可以写一个加载winfrom的用户控件
lh520cq 2013-09-10
  • 打赏
  • 举报
回复
Geomam.UserControl1 xx = new Geomam.UserControl1(); System.Windows.Forms.Integration.WindowsFormsHost host = new System.Windows.Forms.Integration.WindowsFormsHost(); host.Child = xx; this.MStackPanel.Children.Add(host);

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧