PrepAway - Latest Free Exam Questions & Answers

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.)
01public class Contact
02{
03private string _contactName;
04
05public string ContactName {
06get { return _contactName; }
07set { _contactName = value; }
08}
09
10}
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 data-bound 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).

PrepAway - Latest Free Exam Questions & Answers

A.
Replace line 01 with the following code segment. public class Contact : IDataErrorInfo

B.
Replace line 01 with the following code segment. public class Contact : ValidationRule

C.
Replace line 01 with the following code segment. public class Contact : INotifyPropertyChanging

D.
Add the following code segment at line 04. public event PropertyChangingEventHandler PropertyChanging;

E.
Modify line 07 with the following code segment:
set {
if (this.PropertyChanging != null)
PropertyChanging(this, new
PropertyChangingEventArgs(“ContactName”));
if (string.IsNullOrEmpty(value))
throw new ApplicationException(“Contact name is required”);
_contactName = value;
}

F.
Add the following code segment at line 09.
public string Error {
public string this[string columnName] {
get {
if (columnName == “ContactName” &&
string.IsNullOrEmpty(this.ContactName))
return “Contact name is required”;
return null;
}
}


Leave a Reply