PrepAway - Latest Free Exam Questions & Answers

What should you add to constructor of the main window ?

You are developing a Windows Presentation Foundation (WPF) application to play audio files. You add MediaElement mediaElement1 and a Button control named btnPlayAudio to the design surface. The MediaElement co.. audio file. The LoadedBehavior attribute is set to Manual.

You add the following code to the main Window.

void playCommand_Executed(object sender, RoutedEventArgs e)
{
mediaElement1.Play();
}

You set the command of the button to MediaCommands.Play.

You need to ensure that the application will play the audio file when the button is pressed.

What should you add to constructor of the main window ?

PrepAway - Latest Free Exam Questions & Answers

A.
RoutedCommand playCommand = new RoutedCommand();
playCommand.CanExecuteChanged += new EventHandler(playCommand_Executed);
this.CommandBindings.Add(new CommandBinding(playCommand));

B.
RoutedUICommand playCommand = new RoutedUICommand();
playCommand.CanExecuteChanged += new EventHandler(playCommand_Executed);
this.CommandBindings.Add(new CommandBinding(playCommand));

C.
CommandBinding playCommand = new CommandBinding(MediaCommands.Play);
playCommand.CanExecute += new CanExecuteRoutedEventHandler(playCommand_Executed);
this.CommandBindings.Add(playCommand);

D.
CommandBinding playCommand = new CommandBinding(MediaCommands.Play);
playCommand.Executed += new ExecutedRoutedEventHandler(playCommand_Executed);
this.CommandBindings.Add(playCommand);

One Comment on “What should you add to constructor of the main window ?

  1. Mr ijs says:

    Full question text:

    You are developing a Windows Presentation Foundation (WPF) application to play audio files. You add a MediaElement control named mediaElementl and a Button control named btnPlayAudio to the design surface. The MediaElement control Source attribute is set to an audio file. The LoadedBehavior attribute is set to Manual.

    You add the following code to the main window.

    void playCommand_Executed(object sender, RoutedEventArgs e)
    {
    mediaElementl.Play();
    }

    You set the command of the button to MediaCommands.Play.

    You need to ensure that the application will play the audio file when the button is pressed.

    What should you add to the constructor of the main window?




    0



    0

Leave a Reply