c# - Add Windows User Control to a WPF View -


i need add windows form user control (barcode_scanner.cs) wpf view (mainwindow.xaml)

is there simple way this? appreciated.

you can host windows.forms controls using wpf windowsformshost element.

example:

<window x:class="wpfapplication10.mainwindow"         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"         xmlns:winforms="clr-namespace:system.windows.forms;assembly=system.windows.forms"         xmlns:mycontrols="clr-namespace:mycontromnamespace;assembly=mycontromnamespace"         title="mainwindow" height="195" width="191" name="ui">     <grid>         <windowsformshost>             <winforms:button text="stackoverflow" />         </windowsformshost>          <windowsformshost>             <mycontrols:myusercontrol  />         </windowsformshost>      </grid> </window> 

result:

enter image description here


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -