Visual Programming MCQs with Answers
Practice important Visual Programming MCQs with answers and explanations.
Chapter: 24
Q481:
What does the Execute method of an ICommand do?
A. Executes the logic associated with the command
B. Checks if the command can be executed
C. Changes the appearance of the UI element
D. Updates the command's status
Correct Answer:
A
Chapter: 24
Q482:
In the provided XAML example, how is the Help command bound to the button?
A. By setting the Command property to Help
B. By adding a CommandBinding for Help
C. By defining the Help command in the InputBindings section
D. By using the Command property in the code-behind
Correct Answer:
A
Chapter: 24
Q483:
How can you handle multiple commands in a single CommandBinding?
A. By specifying different Executed and CanExecute event handlers for each command
B. By using multiple CommandBindings for different commands
C. By defining a single Executed event handler that switches between commands
D. By creating custom command logic within the CommandBinding event handlers
Correct Answer:
A
Chapter: 24
Q484:
What is the purpose of ApplicationCommands in WPF?
A. To provide a set of predefined commands for common operations
B. To create custom commands for specific controls
C. To handle application-wide events
D. To define custom input gestures for commands
Correct Answer:
A
Chapter: 24
Q485:
How do CommandBindings and InputBindings differ in WPF?
A. CommandBindings are used for defining command logic, while InputBindings handle input gestures
B. CommandBindings handle input gestures, while InputBindings define command logic
C. CommandBindings are for keyboard input, while InputBindings are for mouse input
D. CommandBindings manage application-level commands, while InputBindings are for control-specific commands
Correct Answer:
A
Chapter: 24
Q486:
In the provided code example, what will the helpexecuted method do?
A. Open a URL in the default web browser
B. Change the window title
C. Update the status bar text
D. Show a message box to the user
Correct Answer:
A
Chapter: 24
Q487:
What is the default behavior of Help command in the aboutdialog XAML if not properly bound?
A. The command will be disabled
B. The command will not execute
C. The command will execute but with no effect
D. The command will throw an exception
Correct Answer:
A
Chapter: 25
Q488:
What property can be used to center a WPF window on the screen when it starts?
A. Left and Top
B. WindowStartupLocation
C. Topmost
D. ShowInTaskbar
Correct Answer:
B
Chapter: 25
Q489:
What event is triggered when a WPF window is about to be closed?
A. OnClosing
B. OnClosed
C. OnActivated
D. OnDeactivated
Correct Answer:
A
Chapter: 25
Q490:
How can you ensure a WPF application always starts with a specific window?
A. By setting the StartupUri property in App.xaml
B. By calling Show on the main window in the Main method
C. By setting the MainWindow property in App.xaml.cs
D. By using Application.Run method in Main
Correct Answer:
A
Chapter: 25
Q491:
What method is used to persist data when a WPF application is about to close?
A. OnClosed
B. OnInitializing
C. OnClosing
D. OnExit
Correct Answer:
A
Chapter: 25
Q492:
How do you handle a scenario where you need to ensure only one instance of a WPF application runs?
A. By using a Mutex to check if another instance is already running
B. By using the Dispatcher to prevent multiple instances
C. By checking the process count in the Main method
D. By setting the ShutdownMode to OnExplicitShutdown
Correct Answer:
A
Chapter: 25
Q493:
How do you add a splash screen to a WPF application?
A. By adding a new item with the build action set to SplashScreen in the project properties
B. By setting the SplashScreen property in App.xaml
C. By using SplashScreen class in the application code
D. By defining SplashScreen in the Application class
Correct Answer:
A
Chapter: 25
Q494:
Which property of PrintDialog is used to display the print dialog to the user?
A. ShowDialog
B. Print
C. PrintVisual
D. PrintDocument
Correct Answer:
A
Chapter: 25
Q495:
What method can be used to rename a file in a WPF application?
A. File.Move
B. File.Copy
C. File.Delete
D. File.Rename
Correct Answer:
A
Chapter: 25
Q496:
How can you handle file storage and retrieval using isolated storage in a WPF application?
A. By using IsolatedStorageFile and IsolatedStorageFileStream
B. By using FileStream and File
C. By using ApplicationSettings class
D. By using Registry class
Correct Answer:
A
Chapter: 25
Q497:
What is a modal dialog in WPF?
A. A dialog that blocks user interaction with other windows until it is closed
B. A dialog that can be used without affecting other windows
C. A dialog that shows only when the application starts
D. A dialog that appears in a non-blocking manner
Correct Answer:
A
Chapter: 25
Q498:
What method is called when a WPF window is shown modally?
A. ShowDialog
B. Show
C. Activate
D. Focus
Correct Answer:
A
Chapter: 25
Q499:
What property of a Window determines if it should appear in the taskbar?
A. ShowInTaskbar
B. Topmost
C. WindowStyle
D. AllowsTransparency
Correct Answer:
A
Chapter: 25
Q500:
How do you handle application exit scenarios in WPF?
A. By overriding OnExit method in the Application class
B. By setting the ShutdownMode property in App.xaml
C. By calling Application.Exit() method
D. By handling the Exit event in the main window
Correct Answer:
A