PrepAway - Latest Free Exam Questions & Answers

Which code segment should you insert at line 05?

You use Microsoft .NET Framework 4 to create a Windows Forms application.
You plan to use a Windows Presentation Foundation (WPF) control of the UserControl1 type hosted in an
ElementHost control named elementHost1.
You write the following code segment. (Line numbers are included for reference only.)
01public class WPFInWinForms {
02public WPFInWinForms
03{
04InitializeComponent();
05
06}
07private void OnBackColorChange(object sender, String propertyName, object value)
08{
09ElementHost host = sender as ElementHost;
10System.Drawing.Color col = (System.Drawing.Color)value;
11SolidColorBrush brush =
new SolidColorBrush(System.Windows.Medi
a.Color.FromRgb(col.R, col.G, col.B));
12UserControl1 uc1 = host.Child as UserControl1;
13uc1.Background = brush;
14}
15}
You need to ensure that the application changes the background color of the hosted control when the background color of the form changes.
Which code segment should you insert at line 05?

PrepAway - Latest Free Exam Questions & Answers

A.
elementHost1.PropertyMap.Remove(“BackColor”);
elementHost1.PropertyMap.Add(“BackColor”, new PropertyTranslator(OnBackColorChange));

B.
elementHost1.PropertyMap.Remove(“Background”);
elementHost1.PropertyMap.Add(“Background”, new PropertyTranslator(OnBackColorChange));

C.
elementHost1.PropertyMap.Add(“BackColor”, new PropertyTranslator(OnBackColorChange));
elementHost1.PropertyMap.Apply(“BackColor”);

D.
elementHost1.PropertyMap.Add(“Background”, new PropertyTranslator(OnBackColorChange));
elementHost1.PropertyMap.Apply(“Background”);


Leave a Reply