Which binding expression should you use?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create a Windows Presentation Foundation (WPF) application. You create a WPF window in the application. You add the following code segment to the application.

Public Class ViewModel
Public Property Data() As CollectionView Get End Get Set End Set End Property End Class Public Class BusinessObject Public Property Name() As String Get End Get Set End Set End Property End Class The DataContext property of the window is set to an instance of the ViewModel class. The Data property of the ViewModel instance is initialized with a collection of BusinessObject objects. You add a TextBox control to the window. You need to bind the Text property of the TextBox control to the Name property of the current item of the CollectionView of the DataContext object. You also need to ensure that when a binding error occurs, the Text property of the TextBox control is set to N/A . Which binding expression should you use?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create a Windows Presentation Foundation (WPF) application. You create a WPF window in the application. You add the following code segment to the application.

Public Class ViewModel
Public Property Data() As CollectionView Get End Get Set End Set End Property End Class Public Class BusinessObject Public Property Name() As String Get End Get Set End Set End Property End Class The DataContext property of the window is set to an instance of the ViewModel class. The Data property of the ViewModel instance is initialized with a collection of BusinessObject objects. You add a TextBox control to the window. You need to bind the Text property of the TextBox control to the Name property of the current item of the CollectionView of the DataContext object. You also need to ensure that when a binding error occurs, the Text property of the TextBox control is set to N/A . Which binding expression should you use?

A.
{ Binding Path=Data/Name, FallbackValue=’N/A’ }

B.
{ Binding Path=Data.Name, FallbackValue=’N/A’ }

C.
{ Binding Path=Data/Name, TargetNullValue=’N/A’ }

D.
{ Binding Path=Data.Name, TargetNullValue=’N/A’ }



Leave a Reply 0

Your email address will not be published. Required fields are marked *