1

I have 2 projects, a Winform and WPF. I created a label in Winform, and a ribbon control in WPF. Then I added the ribbon to the winform by adding a reference to WPF and using an elementhost. My goal is to access the label control from the ribbon created in WPF.

The issue is that I can't seem to add a reference back to Winform so I can grab the controls in Winforms from WPF, as this would then create a circular reference. I am not sure how else I can access Winform controls in WPF.

The same question was asked here

But I don't believe this question was answered properly, as the reference only shows the user how to achieve what I've described above. Any help would be appreciated.

Community
  • 1
  • 1
Mike
  • 235
  • 3
  • 15
  • why are you even using winforms? Create the project entirely in WPF and use proper DataBinding and MVVM and forget winforms which is useless and deprecated and does not support anything. – Federico Berasategui Dec 03 '14 at 02:10
  • I do have my reasons. For example, I am using a library that utilizes hdc and native windows APIs. But I couldn't find a way to generate hdc handles in WPF controls. – Mike Dec 03 '14 at 02:14
  • WPF controls don't have any "handles" because they're WPF controls, not windows. Whatever libraries you're trying to use are probably not required in WPF. What are you really trying to do? – Federico Berasategui Dec 03 '14 at 02:18
  • I want to use WPF for the modern form graphics (such as the ribbon), however I need Winforms for the library I'm using. The library I am using was written in C for portability, but it utilizes GDI graphic controls. – Mike Dec 03 '14 at 03:38
  • again, whatever library you might need (mostly if it's related to graphics) can probably be reproduced in a couple of lines of XAML. Also, even if you can't do that, then create your entire application in WPF and then use a winformshost ONLY for the part where you will show these controls. – Federico Berasategui Dec 03 '14 at 04:39
  • You don't need to have two projects for WPF and Winforms. Put both controls in the same project and use it. Or create third project which will contain both controls and use that third library in your WPF or Winforms project – Fabio Dec 03 '14 at 05:52
  • using events for link between WPF controls and win forms [View More Help From This LInk :](https://stackoverflow.com/questions/7880850/how-do-i-make-an-event-in-the-usercontrol-and-have-it-handeled-in-the-main-form) – Novin.Kh Aug 16 '17 at 16:31

0 Answers0