单项选择题
You create a Windows client application by using Windows Presentation Foundation (WPF).
The application contains the following code fragment.
You need to assign lbDetails to use the detail data template when btnDetails is clicked.
Which code segment should you write for the click event handler for btnDetails?()
A. lbDetails.ItemsPanel.FindName("detail",lbDetails);
B. var tmpl = (ControlTemplate)FindResource("detail"); lbDetails.Template = tmpl;
C. var tmpl = (DataTemplate)FindName("detail"); lbDetails.ItemTemplate = tmpl;
D. var tmpl = (DataTemplate)FindResource("detail"); lbDetails.ItemTemplate=tmpl;
相关考题
-
单项选择题
You use Microsoft .NET Framework 4 to create a Windows Presentation Foundation (WPF) application. The application has a window named MainWindow that has a StackPanel control named sp as the root element. You want to create a Button control that contains a TextBlock control with the "Save" Text property. You need to create the control dynamically and add the control to sp. Which code segment should you write in the constructor of the MainWindow class?()
A.
B.
C.
D. -
单项选择题
You use Microsoft .NET Framework 4 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 void CanAddSugar (object sender, CanExecuteRoutedEventArgs e) { ... } 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?()
A. Create an event handler for the CanExecuteChanged event of the AddSugarCommand command. Call the CanAddSugar method from within the event handler.
B. Inherit the AddSugarCommand from the RoutedUICommand class instead of the RoutedCommand class. Call the CanAddSugar method from within the constructor of the AddSugarCommand command.
C. Add a CommandBinding object to the CommandBinding property of the MenuItem control. Set the CanExecute property of the CommandBinding object to the CanAddSugar method.
D. Add a CommandBinding object to the CommandBindings property of the window. Set the Command property of CommandBinding to the AddSugarCommand command. Set the CanExecute property of the CommandBinding object to the CanAddSugar method. -
多项选择题
You use Microsoft .NET Framework 4 to create a Windows Presentation Foundation (WPF) application. The application contains a composite user control that includes a TextBox control named txtInput. The user control will be hosted in a window and will have handlers for the text-changed event of txtInput. You need to ensure that the application meets the following requirements: AddHandler(TextBox.TextChangedEvent, new RoutedEventHandler(Audit_TextChanged), true); Which of the following statments are TRUE ?()
A. A text-changed event handler, named Audit_TextChanged, was Created for the txtInput control.
B. Audit_TextChanged will stop running because the event is marked as handled by certain event handlers.
C. Even through the event is marked handled by certain event handlers, Audit_TextChanged will still run.
D. Audit_TextChanged will continue to run until the event is marked as handled.
