Use vs2008 to create a WPF Application Program To use webbrowser. Adding the webbrowser component from the toolbox to the WPF component finds that many attribute events are unavailable. Decide whether to use webbrowser in winform. To use the winform control in WPF, follow these steps to view msdn.
Create a project namedHostingwfinwpf.
In Solution Explorer, add a reference to the windowsformsintegration Assembly named windowsformsintegration. dll.
In Solution Explorer, add a reference to the Windows form Assembly named system. Windows. Forms. dll.
Open window1.xaml In the WPF Designer.
Replace the automatically generated XAML in window1.xaml with the following XAML.
<Window X: class = "hostingwfinwpf. window1"
Xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Xmlns: x = "http://schemas.microsoft.com/winfx/2006/xaml"
Title = "hostingwfinwpf"
Loaded = "windowloaded"
>
<Grid name = "grid1">
</GRID>
</WINDOW>
6. InCodeOpen window1.xaml. CS in the editor.
7. Replace the code in window1.xaml. CS with the following code.
Using system;
Using system. windows;
Using system. Windows. controls;
Using system. Windows. Data;
Using system. Windows. documents;
Using system. Windows. Media;
Using system. Windows. shapes;
Using system. Windows. forms;
Namespace hostingwfinwpf
{
Public partial class window1: Window
{
Public window1 ()
{
Initializecomponent ();
}
Private void windowloaded (Object sender, routedeventargs E)
{
// Create the InterOP Host Control.
System. Windows. Forms. Integration. windowsformshost host =
New system. Windows. Forms. Integration. windowsformshost ();
// Create the maskedtextbox control.
Maskedtextbox mtbdate = new maskedtextbox ("00/00/0000 ");
// Assign the maskedtextbox control as the Host Control's child.
Host. Child = mtbdate;
// Add the InterOP Host Control to the grid
// Control's collection of child controls.
This. grid1.children. Add (host );
}
}
}
Replace maskedtextbox with system. Windows. Forms. webbrowser.