【问题标题】:How to access winforms data from wpf interop?如何从 wpf 互操作访问 winforms 数据?
【发布时间】:2009-12-23 08:41:25
【问题描述】:

我的解决方案中有 2 个项目。

-WindowsFormsApplication8
-WpfControlLibrary1

我正在使用 WPF Interoperability 中的 ElementHost 来托管 WpfControlLibrary1 中的 UserControl1。

_________________________
Form1             - [] x |
-------------------------

  ..........
  | label1 |  // label
  ..........

// elementHost1 
// wpf control has one 
// button and nothing else
   ____________
  |            |
  |  ClickMe1  |
  |____________|

__________________________

现在,

<Canvas>
    <Button Click="btnclick">hello</Button>
</Canvas>

private void btnclick(object sender, RoutedEventArgs e)
{
    MessageBox.Show(); // this msgbox
}


我希望“this msgbox”显示 label1 的内容。

我该怎么做?

【问题讨论】:

    标签: c# wpf winforms winforms-interop


    【解决方案1】:

    我改变了答案。这个网站对你做这两种方式都很有用:

    http://sachabarber.net/?p=149

    【讨论】:

    • @pipelinecache 请发布一个例子,没有它我太笨了! :)
    • 嗨,大卫,是的,我可以,只需几分钟。等等。
    • 谢谢,我只希望我有更多的时间来写博客。
    猜你喜欢
    • 2010-11-15
    • 1970-01-01
    • 1970-01-01
    • 2011-09-26
    • 1970-01-01
    • 2023-03-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多