Here, we will be working with adding Windows Forms in Windows Presentation Foundation (WPF)
What is Winform?Windows Form is a segment of Microsoft .NET framework. It is a GUI (Graphical User Interface) class library, which allows us to write the rich looking Client Applications for tablets, laptops and Desktops.
Follow the following steps to add Winforms in WPF:
Step 1:Run Visual Studio 2015 -> Visual C# -> Windows -> WPF Application
Step 2:Right click on the references and add the following reference files:
WindowsFormsIntegeration:Click here to know about WindowsFormsIntegeration Namespace.
System.Windows.Forms:Click here to know about System.Windows.Forms Namespace
Here, you can find both the reference files that are added under references.
Step 3:Add the following namespacing too,
Now, paste the code, given below, at MainWindow.xaml under Grid or drag and drop the WindowsFormHost tool.
<WindowsFormsHost> <wf:MaskedTextBox x:Name="mtbDate" Mask="00/00/0000" /> </WindowsFormsHost>
Step 4:Now, run the code by clicking Start at the top pane of Visual Studio 2015.
You will be getting the following Window:
This Application will allow you to enter the date in Windows Form at WPF Application.
SummaryThis is a basic example to work with Windows Forms on WPF (Windows Presentation Foundation). WPF is a new technology compared to Winforms.