Reputation: 105
I have a WinForms User Control (a toolbar) which i would like to add on a WPF user Control, is there any way to do this?
like i want a WinForms User Control (the toolbar) along with other WPF Controls (datagrid) on a new WPF User Control
I saw a couple of samples that show Windows Forms hosted in a WPF Control. But that is not what i want to see.
Upvotes: 0
Views: 695
Reputation: 51
You can check out my answer to a similar question here:
WPF hosting a WinForm, Tab Navigation problems
This will also show you how to fix a tabbing issue with windows controls that are sitting inside wpf views.
Upvotes: 0
Reputation: 15704
This is pretty easy to pull off. There is a handy little thing known as WindowsFormHost
all you have to do is declare it in your control's XAML, and nest your forms control inside of it, like so:
<UserControl>
...
<Grid>
<WindowsFormsHost>
<forms:MyFormsToolbarControl/>
</WindowsFormHost>
</Grid>
...
WindowsFormHost
lives inside of the normal WPF toolbox so it shouldn't be hard to locate. Meanwhile there is an example of how to produce the equivalent XAML in code at this location...
http://msdn.microsoft.com/en-us/library/ms751761.aspx
Upvotes: 1