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 ?

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 ?

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



Leave a Reply 1

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


Mr ijs

Mr ijs

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?