Ensurepass

QUESTION 1

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

clip_image002

You create an event handler named StackPanel_PreviewTextInput. You also have a collection of strings named Keywords. You need to ensure that TxtBoxAand TxtBoxB do not contain any of the strings in the Keywords collections. Which code segment should you use?

A.    clip_image004

 

B.    clip_image006

 

C.    clip_image008

 

D.    clip_image010

 

Correct Answer: D

 

QUESTION 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_TextChangedfor the txtInput control.

·         Executes Audit_TextChangedeven when specific handlers mark the event as handled.

Which code segment should you add to the constructor of the user control?

 

A.    txtInput.TextChanged += Audit_TextChanged;

B.    AddHandler(TextBox.TextChangedEvent, new RoutedEventHandler(Audit_TextChanged), true);

C.    EventManager.RegisterClassHandler(typeof(TextBox),TextBox.TextChangedEvent, new RoutedEventHandler(Audit_TextChanged), true);

D.    EventManager.RegisterClassHandler(typeof(TextBox),TextBox.TextChangedEvent, new RoutedEventHandler (Audit_TextChanged), false);

 

Correct Answer: B

 

QUESTION 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)

 

A.    A text-changed event handler, named Audit_TextChanged, was Created for the txtInputcontrol.

B.    Audit_TextChangedwill stop running because the event is marked as handled by certain event handlers.

C.    Even through the event is marked handled by certain event handlers, Audit_TextChanged will still run.

D.    Audit_TextChangedwill continue to run until the event is marked as handled.

 

Correct Answer: AC

 

 

QUESTION 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?

A.    Create an event handler for the CanExecuteChangedevent of the AddSugarCommandcommand.

Call the CanAddSugarmethod from within the event handler.

 

B.    Inherit the AddSugarCommandfrom the RoutedUICommandclass instead of the RoutedCommandclass.

Call the CanAddSugarmethod from within the constructor of theAddSugarCommandcommand.

 

C.    Add a CommandBindingobject to the CommandBindingproperty of the MenuItem control.

Set the CanExecuteproperty of the CommandBindingobject to the CanAddSugarmethod.

 

D.    Add a CommandBindingobject to the CommandBindingsproperty of the window.

Set the Commandproperty of CommandBindingto the AddSugarCommandcommand.

Set the CanExecute property of the CommandBindingobject to the CanAddSugarmethod.

 

Correct Answer: D

 

QUESTION 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?

 

A.    Button btn = new Button();

TextBlock text = new TextBlock();text.

Text = “Save”;

btn.Content = text;

sp.DataContext = btn;

 

B.    Button btn = new Button();

TextBlock text = new TextBlock();

text.Text = “Save”;

btn.Content = text;

sp.Children.Add(btn);

 

C.    Button btn = new Button();

TextBlock text = new TextBlock();

text.Text = “Save”;

sp.Children.Add(btn);

sp.Children.Add(text);

 

D.    Button btn = new Button();TextBlock text = new

TextBlock();text.Text = “Save”;

btn.ContentTemplateSelector.SelectTemplate(text, null);

sp.Children.Add(btn);

 

Correct Answer: B

 

 

QUESTION 6

You create a Windows client application by using Windows Presentation Foundation (WPF). The application contains the following code fragment.

clip_image012

You need to assign lbDetailsto use the detail data template when btnDetails is clicked. Which code segment should you write for the click event handler for btnDetails?

 

A.    lbDetails.ItemsPanel.FindName(“detail”, lbDetails);

B.    var tmpl = (ControlTemplate)FindResource(“detail”);lbDetails.Template = tmpl;

C.    var tmpl = (DataTemplate)FindName(“detail”);lbDetails.ItemTemplate = tmpl;

D.    var tmpl = (DataTemplate)FindResource(“detail”);lbDetails.ItemTemplate = tmpl;

 

Correct Answer: D

 

 

QUESTION 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?

 

A.    Write the following code segment in the button onclick event.

System.Media.SoundPlayer player = new System.Media.

SoundPlayer(SoundFilePath);

player.play();

 

B.    Write the following code segment in the button onclick event.

MediaPlayer player = new MediaPlayer();

player.Open(new URI(SoundFilePath), UriKind.Relative));

player.play();

 

C.    Use the following code segment from the PlaySound() Win32 API function and call the PlaySound function in the button onclick event.

[sysimport(dll=”winmm.dll”)]

public static extern long PlaySound(String SoundFilePath, long hModule, long dwFlags);

 

D.    Reference the Microsoft.DirectX Dynamic Link Libraries. Use the following code segment in the button onclick event.

Audio song = new Song(SoundFilePath);

song.CurrentPosition = song.Duration;

song.Play();

 

Correct Answer: B

 

 

QUESTION 8

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

clip_image014

You need to ensure that the ButtonHandlermethod is not executed when the user clicks the CancelButtonbutton. Which code segment should you add to the code-behind file?

 

A.    private void CancelClicked(object sender, RoutedEventArgs e)

{

      Button btn = (Button)sender;

      btn.Command = null;

}

 

B.    private void CancelClicked(object sender, RoutedEventArgs e)

{

      Button btn = (Button)sender;

      btn.IsCancel = true;

}

 

C.    private void CancelClicked(object sender, RoutedEventArgs e)

{

e.Handled = true;

}

 

D.    private void CancelClicked(object sender, RoutedEventArgs e)

{

e.Handled = false;

}

 

Correct Answer: C

 

 

QUESTION 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.

clip_image016

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’ }

 

Correct Answer: A

 

 

QUESTION 10

You use Microsoft .NET Framework 4 to create a Windows Forms application.

You add a new class named Customer to the application. You select the Customer class to create a new object data source. You add the following components to a Windows Form:

·         A BindingSource component named customerBindingSource that is data-bound to the Customer object data source.

·         A set of TextBox controls to display and edit the Customer object properties.

·         Each TextBox control is data-bound to a property of the customerBindingSource component.

·         An ErrorProvider component named errorProvider that validates the input values for each TextBox control.

You need to ensure that the input data for each TextBox control is automatically validated by using the ErrorProvider component. Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)

 

A.            Implement the validation rules inside the Validating event handler of each TextBox control by throwing an exception when the value is invalid.

 

B.            Implement the validation rules inside the TextChanged event handler of each TextBox control by throwing an exception when the value is invalid.

 

C.            Implement the validation rules inside the setter of each property of the Customer class by throwing an exception when the value is invalid.

 

D.            Add the following code segment to the InitializeComponent method of the Windows Form.this.errorProvider.DataSource = this.customerBindingSource;

 

E.            Add the following code segment to the InitializeComponent method of the Windows Form.

this.errorProvider.DataSource = this.customerBindingSource.DataSource;

this.errorProvider.DataMember = this.customerBindingSource.DataMember;

 

Correct Answer: CD

 

Download Latest MCTS 70-511 Real Free Tests , help you to pass exam 100%.

Comments are closed.