本文介绍了如何从WPF Interop访问Winforms数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

There are 2 projects in my Solution.

-WindowsFormsApplication8
-WpfControlLibrary1

我正在使用WPF互操作性的ElementHost从WpfControlLibrary1托管UserControl1.

I am using ElementHost from WPF Interoperability to host UserControl1 from the WpfControlLibrary1.

_________________________
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
}


我希望此msgbox"显示label1的内容.


I want "this msgbox" to show contents of label1.

我该怎么做?

推荐答案

我更改了答案.该网站对您进行两种方式都很有用:

I changed my answer. This site is usefull for you to do both ways:

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

这篇关于如何从WPF Interop访问Winforms数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 22:58