1.
You use Microsoft .NET Framework 4 to create a Windows Presentation Foundation (WPF) application.
You write the following code fragment.

You create an event handler named StackPanel_PreviewTextInput. You also have a collection of strings named Keywords. You need to ensure that TxtBoxA and TxtBoxB do not contain any of the strings in the Keywords collections. Which code segment should you use?
2.
You use Microsoft .NET Framework 4 to create a Windows Presentation Foundation (WPF) application.
The application contains a composite user control that includes a TextBox control named txtInput. The user control will be hosted in a window and will have handlers for the text-changed event of txtInput. You need
to ensure that the application meets the following requirements:
Creates a text-changed event handler named Audit_TextChanged for the txtInput control.
Executes Audit_TextChanged even when specific handlers mark the event as handled.
Which code segment should you add to the constructor of the user control?
3.
You use Microsoft .NET Framework 4 to create a Windows Presentation Foundation (WPF) application. The application contains a composite user control that includes a TextBox control named txtInput. The user control will be hosted in a window and will have handlers for the text-changed event of txtInput. You need to ensure that the application meets the following requirements: AddHandler(TextBox.TextChangedEvent, new RoutedEventHandler(Audit_TextChanged), true); Which of the following statements are TRUE? (choose all that apply)
4.
You use Microsoft .NET Framework 4 to create a Windows Presentation Foundation (WPF) application.
You create a window that contains a Button control and a MenuItem control. Both controls are labeled "Add sugar." The Command properties of the Button and MenuItem controls are set to the same RoutedCommand named AddSugarCommand. You write the following code segment. private void CanAddSugar (object sender, CanExecuteRoutedEventArgs e) { ... }
You need to ensure that when the CanAddSugar method sets e.CanExecute to false, the MenuItem and Button controls are disabled. What should you do?
5.
You use Microsoft .NET Framework 4 to create a Windows Presentation Foundation (WPF) application. The application has a window named MainWindow that has a StackPanel control named sp as the root element.
You want to create a Button control that contains a TextBlock control with the "Save" Text property. You need to create the control dynamically and add the control to sp. Which code segment should you write in the
constructor of the MainWindow class?
6.
You create a Windows client application by using Windows Presentation Foundation (WPF).
The application contains the following code fragment.



You need to assign lbDetails to use the detail data template when btnDetails is clicked.
Which code segment should you write for the click event handler for btnDetails?
7.
You use Microsoft .NET Framework 4 to create a Windows Presentation Foundation (WPF) application.
You want to add an audio player that plays .wav or .mp3 files when the user clicks a button. You plan to store the name of the file to a variable named SoundFilePath. You need to ensure that when a user clicks the button, the file provided by SoundFilePath plays. What should you do?
8.
You use Microsoft .NET Framework 4 to create a Windows Presentation Foundation (WPF) application.
You write the following code fragment.




You need to ensure that the ButtonHandler method is not executed when the user clicks the CancelButton button. Which code segment should you add to the code-behind file?
9.
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 CollectionView Data { get; set; }
}
public class BusinessObject
{
public string Name { get; set; }
}
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?
10.
You use Microsoft .NET Framework 4 to create a Windows Presentation Foundation (WPF) application.
You write the following code segment.

public class Contact {
private string _contactName;
public string ContactName {
get { return _contactName; }
set {
if (string.IsNullOrEmpty(value)) throw new ApplicationException
("Contact name is required");
_contactName = value;
}
}
}
You add the following code fragment in a WPF window control.

The TextBox control is data-bound to an instance of the Contact class. You plan to implement an
ErrorTemplate in the TextBox control. You need to ensure that the validation error message is displayed next to the TextBox control. Which code fragment should you use?