nerdexam
Microsoft

70-511 · Question #142

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 ElementHos1 control…

The correct answer is A. elementHostl.PropertyMap.Remove("BackColor"). See the full explanation below for the reasoning.

Question

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 ElementHos1 control named elementHost1. You write the following code segment. (Line numbers are included for reference only.) 01 Public Class UPFInUInforms 02 Public Sub WPFInWInforms() 03 InitializeComponent() 04 05 End Sub 06 Private Sub OnBackColorChange(ByVal sender As Object, ByVal propertyName As [String], ByVal value As Object) 07 Dim host As ElementHost = TryCast(sender, ElementHost) 08 Dim col As System.Drawing.Color = DirectCast(value, System.Drawing.Color) 09 Dim brush As New SolidColorBrush(System.Windows.Media.Color.FromRgb(col,R, col.G, col.B)) 10 Dim ucl As UserControll = TryCast(host.Child, UserControll) 11 ucl.Background = brush 12 End Sub 13 End Class 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 04?

Options

  • AelementHostl.PropertyMap.Remove("BackColor")
  • BelementHost1.PropertyMap.Remove("Background")
  • CelementHostl.PropertyMap.Add("BackColor", New
  • DelementHostl.PropertyMap.Add("Background", New

How the community answered

(26 responses)
  • A
    73% (19)
  • B
    8% (2)
  • C
    4% (1)
  • D
    15% (4)

Community Discussion

No community discussion yet for this question.

Full 70-511 Practice