You create a form by using Windows Presentation Foundation. You use Microsoft .NET Framework 3.5 to create the form.
You add a ContextMenu control to the text box named myText on the form. You add the following menu items to the control:
* Copy
* Paste
You need to ensure that the following requirements are met:
* You can copy and paste text.
* The ContextMenu items have input text gestures.
* You can copy and paste text by either clicking the menu items or by using keyboard shortcuts.
You want to achieve this goal by using the least possible code.
Which code fragment should you use?
A.
<TextBox Name="myText">
<TextBox.ContextMenu>
<ContextMenu>
<MenuItem Command="ApplicationCommands.Copy"/>
<MenuItem Command="ApplicationCommands.Paste"/>
</ContextMenu>
</TextBox.ContextMenu>
</TextBox>
B.
<TextBox Name="myText">
<TextBox.CommandBindings>
<CommandBinding Command="ApplicationCommands.Copy"/>
<CommandBinding Command="ApplicationCommands.Paste"/>
</TextBox.CommandBindings>
<TextBox.ContextMenu>
<ContextMenu>
<MenuItem Command="ApplicationCommands.Copy" Header="Copy" InputGestureText="Ctrl+C"/>
<MenuItem Command="ApplicationCommands.Paste" Header="Paste" InputGestureText="Ctrl+V"/>
</ContextMenu>
</TextBox.ContextMenu>
</TextBox>
C.
<TextBox Name="myText">
<TextBox.InputBindings>
<KeyBinding Command="ApplicationCommands.Copy" Modifiers="Control" Key="C"/>
<KeyBinding Command="ApplicationCommands.Paste" Modifiers="Control" Key="V"/>
</TextBox.InputBindings>
<TextBox.ContextMenu>
<ContextMenu>
<MenuItem Command="ApplicationCommands.Copy" Header="Copy" InputGestureText="Ctrl+C"/>
<MenuItem Command="ApplicationCommands.Paste" Header="Paste" InputGestureText="Ctrl+V"/>
</ContextMenu>
</TextBox.ContextMenu>
</TextBox>
D.
<TextBox Name="myText">
<TextBox.InputBindings>
<KeyBinding Command="ApplicationCommands.Copy" Modifiers="Control" Key="C"/>
<KeyBinding Command="ApplicationCommands.Paste" Modifiers="Control" Key="V"/>
</TextBox.InputBindings>
<TextBox.CommandBindings>
<CommandBinding Command="ApplicationCommands.Copy"/>
<CommandBinding Command="ApplicationCommands.Paste"/>
</TextBox.CommandBindings>
<TextBox.ContextMenu>
<ContextMenu>
<MenuItem Command="ApplicationCommands.Copy" Header="Copy"/>
<MenuItem Command="ApplicationCommands.Paste" Header="Paste"/>
</ContextMenu>
</TextBox.ContextMenu>
</TextBox>