PrepAway - Latest Free Exam Questions & Answers

What should you do?

You use Microsoft .NET Framework 4 to create a Windows Presentation Foundation (WPF) application.
You add a custom command as a resource. The key of the command is saveCommand.
You write the following code fragment. (Line numbers are included for reference only.)
01<Canvas>
02
03<Button>
04
05</Button>
06</Canvas>
You need to ensure that saveCommand is executed when the user clicks the Button control.
What should you do?

PrepAway - Latest Free Exam Questions & Answers

A.
Insert the following code fragment at line 04.
<Button.Command>
<StaticResource ResourceKey=”saveCommand” />
</Button.Command>

B.
Insert the following code fragment at line 04.
<Button.CommandBindings>
<CommandBinding Command=”{StaticResource saveCommand}” />
</Button.CommandBindings>

C.
Insert the following code fragment at line 02.
<Canvas.CommandBindings>
<CommandBinding Command=”{StaticResource saveCommand}” />
</Canvas.CommandBindings>
Replace line 03 with the following code fragment.
<Button CommandTarget=”{Binding RelativeSource={RelativeSource Self}, Path=Parent}”>

D.
Insert the following code fragment at line 02.
<Canvas.CommandBindings>
<CommandBinding Command=”{StaticResource saveCommand}” />
</Canvas.CommandBindings>
Replace line 03 with the following code fragment.
<Button CommandParameter=”{Binding RelativeSource={RelativeSource Self}, Path=Parent}”>


Leave a Reply