Commonly Asked WPF Interview Questions and Answers (Part 1)
Commonly Asked WPF Interview Questions and Answers (Part 1)
In this aritcle on "Commonly Asked WPF Interview Questions and Answers (Part 1)", I will focus on very simple and basic WPF interview questions which a WPF developer should know. These WPF interview questions are based on general introduction of WPF, XAML, MVVM Pattern, Comparison of WPF and Silverlight, Layout Panels in WPF and WPF UserControls / CustomControls.
1. What is WPF?
The Windows Presentation Foundation is Microsofts next generation UI framework to create applications with a rich user experience. It is part of the .NET framework 3.0 and higher.
WPF combines application UIs, 2D graphics, 3D graphics, documents and multimedia into one single framework. Its vector based rendering engine uses hardware acceleration of modern graphic cards. This makes the UI faster, scalable and resolution independent.
2. What is XAML?
Extensible Application Markup Language, or XAML (pronounced "zammel"), is an XML-based markup language developed by Microsoft. XAML is the language behind the visual presentation of an application that you develop in Microsoft Expression Blend, just as HTML is the language behind the visual presentation of a Web page. Creating an application in Expression Blend means writing XAML code, either by hand or visually by working in the Design view of Expression Blend.
3. What is MVVM Pattren?
Model-View-ViewModel (MVVM) pattern splits the User Interface code into 3 conceptual parts - Model, View and ViewModel.
Model is a set of classes representing the data coming from the services or the database.
View is the code corresponding to the visual representation of the data the way it is seen and interacted with by the user.
ViewModel serves as the glue between the View and the Model. It wraps the data from the Model and makes it friendly for being presented and modified by the view. ViewModel also controls the View's interactions with the rest of the application
4. What is the difference between MVVM and MVC patterns?
MVVM Model-View ViewModel is similar to MVC, Model-View Controller.
The controller is replaced with a View Model. The View Model sits below the UI layer. The View Model exposes the data and command objects that the view needs. You could think of this as a container object that view goes to to get its data and actions from. The View Model pulls its data from the model.
5. What are the similarities and differences between WPF and Silverlight?
Similarities between Silverlight and WPF
1. Silverlight and WPF both use XAML.
2. Silverlight and WPF share same syntax, code and libraries.
2. Silverlight and WPF share same syntax, code and libraries.
Difference between WPF and Silverlight
1. WPF is tool for writing full-featured desktop applications that run on Windows while Silverlight is for web application.
2. WPF competes with Windows Forms only for writing desktop applications while Silverlight competes with Flash, Java web apps etc.
6. What is the need of layout panels in WPF?
Layout of controls is critical to an applications usability. Arranging controls based on fixed pixel coordinates may work for an limited enviroment, but as soon as you want to use it on different screen resolutions or with different font sizes it will fail. WPF provides a rich set built-in layout panels that help you to avoid the common pitfalls.
7. What are the different types of layout panels in WPF?
There are mainly 5 types of layout panels in WPF. These are:
Grid Panel
Stack Panel
Dock Panel
Wrap Panel
Canvas Panel
Stack Panel
Dock Panel
Wrap Panel
Canvas Panel
8. How to create a User Control and then how to use it in a WPF application?
User Controls are commonly used in a WPF application. So you should know this concept and you should be able to write a simple program to show how usercontrols are created and used in WPF application. I am sharing a link which created and uses usercontrol in very simple manner. Have a look:
9. What is the difference between UserControl and CustomControl in WPF?
UserControl (Composition)
Composes multiple existing controls into a reusable "group"
Consists of a XAML and a code behind file
Cannot be styled/templated
Derives from UserControl
Consists of a XAML and a code behind file
Cannot be styled/templated
Derives from UserControl
CustomControl (Extending an existing control)
Extends an existing control with additional features
Consists of a code file and a default style in Themes/Generic.xaml
Can be styled/templated
The best approach to build a control library
Consists of a code file and a default style in Themes/Generic.xaml
Can be styled/templated
The best approach to build a control library