WPF Interview Questions
WPF Interview Questions
Fired when an application gets focus, i.e. becomes the foreground application* Deactivated
Fired when application loses focus, i.e. is no longer the foreground application*
DispatcherUnhandledException
Fired when an exception is thrown, but not yet handled. You canchoose to handle the
exception or not* SessionEnding
due to either logoff or Windows shutdown.You can cancel the shutdown sequence.* You can
add custom code for any of these events by just overriding the OnEventName method in
yourApplication-derived class, e.g. OnStartup.
Question: 70What is the series of Window Events at Startup in WPF?Ans:
* At application startup, the Window events that are fired (in order) for the main window
are:1) Initialized - Main window is being created2) IsVisibleChanged - IsVisible property
set to true3) SizeChanged - Size property set to size of window4) LayoutUpdated Window layout changes5) SourceInitialized - Window is attached to Win32 window
handle6) Activated - Window becomes foreground window7) PreviewGotKeyboardFocus Window getting focus
By Jignesh Patel ([email protected]) Page 148) IsKeyboardFocusWithinChanged IsKeyboardFocusWithin property set to true9) IsKeyboardFocusedChanged IsKeyboardFocused property set to true10) GotKeyboardFocus - Window now has
keyboard focus11) LayoutUpdated - Window layout changes12) Loaded - Window is now laid
out, fully rendered13) ContentRendered - All window content has been rendered
Question: 71What is the series of event fired for application shutdown in WPF?Ans:
1) Closing - Window is going to close2) IsVisibleChanged - IsVisible property set to
false3) Deactivated - Window becomes background window4)
IsKeyboardFocusWithinChanged - IsKeyboardFocusWithin property set to false5)
IsKeyboardFocusedChanged - IsKeyboardFocused property set to false6)
LostKeyboardFocus - Window no longer has keyboard focus7) Closed - Window is closing
Question: 72How to Creating Windows Forms Controls Dynamically in WPF?Ans:
1) Import the following namespaces:using System.Windows.Forms;using
System.Windows.Forms.Integration;2) Create the windows forms control and set its
properties and event handlers.3) Add the control to the 'Child' property of
'WindowsFormsHost' object.4) Add the host object to the 'Children' collection of the
panel.
Question: 73How to host WPF Controls in Windows Forms?Ans:
1) Add reference to the following:a) Presentation Coreb) Presentation Frameworkc)
WindowsBased) WindowsFormsIntegratione) System.Xaml2) Also add reference to the
WPF control DLL.3) Use the 'ElementHost' control in 'WPF Interoperability' tab in
Toolbox to host WPF controls.
A WPF control consists of multiple, more primitive controls. A button - for example
- consists of aborder, a rectangle and a content presenter. These controls are visual
children of the button.When WPF renders the button, the element itself has no
appearance, but it iterates through the visualtree and renders the visual children of it.
This hierarchical relation can also be used to do hit-testing,layout etc.But sometimes you
are not interested in the borders and rectangles of a controls' template.
Particularlybecause the template can be replaced, and so you should not relate on the
visual tree structure!Because of that you want a more robust tree that only contains the
"real" controls - and not all thetemplate parts. And that is the eligibility for the logical
tree.
Activity (4)
FILTERS
Add to collectionReviewAdd NoteLike
1 hundred reads
1 thousand reads
nats007 liked this
Mohit Agarwal liked this
Download and