Which two actions should you perform?

You use Microsoft .NET Framework 4 to create a Windows Presentation Foundation (WPF) application. You write the following code segment. (Line numbers are included for reference only.) 01 Public Class Contact 02 Private _contactName As String 03 04 Public Property ContactName() As String 05 Get 06 Return _contactName 07 End Get 08 Set 09 _contactName = value 10 End Set 11 End Property 12 13 End Class You add the following code fragment within a WPF window control. <TextBox> <TextBox.Text> <Binding Path=”ContactName” UpdateSourceTrigger=”PropertyChanged”> <Binding.ValidationRules> <DataErrorValidationRule /> </Binding.ValidationRules> </Binding> </TextBox.Text> </TextBox>

The TextBox control is databound to an instance of the Contact class. You need to ensure that the Contact class contains a business rule to ensure that the ContactName property is not empty or NULL. You also need to ensure that the TextBox control validates the input data. Which two actions should you perform? (Each correct answer presents part of the solution.
Choose two).

You use Microsoft .NET Framework 4 to create a Windows Presentation Foundation (WPF) application. You write the following code segment. (Line numbers are included for reference only.) 01 Public Class Contact 02 Private _contactName As String 03 04 Public Property ContactName() As String 05 Get 06 Return _contactName 07 End Get 08 Set 09 _contactName = value 10 End Set 11 End Property 12 13 End Class You add the following code fragment within a WPF window control. <TextBox> <TextBox.Text> <Binding Path=”ContactName” UpdateSourceTrigger=”PropertyChanged”> <Binding.ValidationRules> <DataErrorValidationRule /> </Binding.ValidationRules> </Binding> </TextBox.Text> </TextBox>

The TextBox control is databound to an instance of the Contact class. You need to ensure that the Contact class contains a business rule to ensure that the ContactName property is not empty or NULL. You also need to ensure that the TextBox control validates the input data. Which two actions should you perform? (Each correct answer presents part of the solution.
Choose two).

A.
Replace line 01 with the following code segment. Public Class Contact Implements IDataErrorInfo

B.
Replace line 01 with the following code segment. Public Class Contact Inherits ValidationRule

C.
Replace line 01 with the following code segment. Public Class Contact Implements INotifyPropertyChanging

D.
Add the following code segment at line 03. Public Event PropertyChanging As PropertyChangingEventHandler Modify line 08 with the following code segment: Set If Me.PropertyChanging <> Nothing Then PropertyChanging(Me, New PropertyChangingEventArgs(“ContactName”)) End If If String.IsNullOrEmpty(value) Then Throw New ApplicationException(“Contact name is required”) End If _contactName = value End Set

E.
Add the following code segment at line 12. Public ReadOnly Property [Error]() As String Get Throw New Exception(string.Empty) End Get End Property Public Default ReadOnly Property Item(columnName As String) As String Get If columnName = “ContactName” AndAlso String.IsNullOrEmpty(Me.ContactName) Then Return “Contact name is required” End If Return Nothing End Get End Property



Leave a Reply 0

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