PrepAway - Latest Free Exam Questions & Answers

What should you do?

You use Microsoft .NET Framework 4 to create a Windows Presentation Foundation (WPF) application.
You plan to use an existing Windows Forms control named MyWinFormControl in the MyControls assembly.
You need to ensure that the control can be used in your application.
What should you do?

PrepAway - Latest Free Exam Questions & Answers

A.
Add the following code fragment to the application.
<Window x:Class=”HostingWfInWpf.Window1″
xmlns=”http: //schemas.microsoft.com/winfx/2006/xaml/presentation”
xmlns:x=”http: //schemas.microsoft.com/winfx/2006/xaml”
xmlns:wf=”clr-namespace:MyCompany.Controls;assembly=MyControls;” Title=”HostingWfInWpf” >
<Grid>
<ElementHost>
<wf:MyWinFormControl x:Name=”control” />
</ElementHost>
</Grid> </Window>

B.
Add the following code fragment to the application.
<Window x:Class=”HostingWfInWpf.Window1″
xmlns=”http: //schemas.microsoft.com/winfx/2006/xaml/presentation”
xmlns:x=”http: //schemas.microsoft.com/winfx/2006/xaml”
xmlns:wf=”clr-namespace:MyCompany.Controls;assembly=MyControls;” Title=”HostingWfInWpf” >
<Grid>
<WindowsFormsHost>
<wf:MyWinFormControl x:Name=”control” />
</WindowsFormsHost>
</Grid> </Window>

C.
Add the following code segment to the WindowsLoaded function.
ElementHost host = new ElementHost();
host.Dock = DockStyle.Fill;
MyWinFormControl control = new MyWinFormControl();
host.Child = control;
this.Controls.Add(host);

D.
Add the following code segment to the WindowsLoaded function.
Grid grid = new Grid();
System.Windows.Forms.Integration.WindowsFormsHost host = new
System.Windows.Forms.Integration.WindowsFormsHost();
MyWinFormControl control = new MyWinFormControl();
grid.Children.Add(host);


Leave a Reply