Microsoft
70-511 · Question #172
70-511 Question #172: Real Exam Question with Answer & Explanation
The correct answer is D. Add a CommandBinding object to the CommandBindings property of the window.. See the full explanation below for the reasoning.
Question
You use Microsoft .NET Framework 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 Sub CanAddSugar(sender As Object, e As CanExecuteRoutedEventArgs) ... End Sub 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?
Options
- ACreate an event handler for the CanExecuteChanged event of the AddSugarCommand
- BInherit the AddSugarCommand from the RoutedUICommand class instead of the
- CAdd a CommandBinding object to the CommandBinding property of the MenuItem control.
- DAdd a CommandBinding object to the CommandBindings property of the window.
Community Discussion
No community discussion yet for this question.