WPF Interview Questions And Answers
What is WPF?
WPF (Windows Presentation foundation) is a graphical subsystem for displaying user interfaces, documents, images, movies etc in windows application.
What is the need of WPF when we had windows forms?
A – Anywhere execution ( Windows or Web)
B – Bindings ( less coding)
C – Common look and feel ( resource and styles)
D – Declarative programming (XAML)
E – Expression blend animation ( Animation ease)
F – Fast execution ( Hardware acceleration)
G – Graphic hardware independent ( resolution independent)
I would strongly suggest you to see the below videowhich explains all the above A to G points practically.
What are static and dynamic resources?
XAML is a XML file which represents your WPF UI training in Hyderabad. The whole point of creating the UI representation in XML was write once and run it anywhere. So the same XAML UI can be rendered as windows application with WPF and the same UI can be displayed on the browser using WPF browser or Silverlight application.
XAML is an XML file which represents your WPF UI. The whole point of creating the UI representation in XML was write once and run it anywhere. So the same XAML UI can be rendered as windows application with WPF and the same UI can be displayed on the browser using WPF browser or Silverlight application.
What is MVVM?
Answer: MVVM (Model View ViewModel) is a framework for making applications in WPF. MVVM is the same as the MVC framework. It is a 3-tier architecture plus one more layer. We can do loose coupling using MVVM.
MVVM was introduced by John Gossman in 2005 specifically for use with WPF as a concrete application of Martin Fowler’s broader Presentation Model pattern. The implementation of an application, based on the MVVM patterns, uses various platform capabilities that are available in some form for WPF, Silverlight Desktop/web, and on Windows. Many commercial applications, including Microsoft Expression products, were built following MVVM.
Advantage of MVVM
Test driven approach.
Separation UI and Business layer as view and view model.
Code sharing between pages and forms.
Easy to Maintain.
List of features of MVVM
It separates the business and presentation layers, like MVP and MVC.
Improve Structure/separation of concerns (View, ViewModel and Model).
Enable a better Design/Developer Workflow.
Enhance simplicity and testability.
Enabled by the robust data binding capability of XAML.
No need to use a code behind file (minimalist code-behind file).
Provides application development ability for multiple environments.
Powerful Data Binding, command, validation and much more.
The designer and developer can work together.
Describe how you would go about writing your own button style?
Make sure the interviewee understands the following:
– How to copy the default style using Expression Blend.
– How to change the style
– How there must be a Style for each state: Enabled, Disabled, Mouseover, pushed, etc…
You need to display a list of items. Which controls are possible options? Of those, which would you use and why?
ItemsControl, ListBox, ListView, DataGrid.
– Make sure they know that ListBox and ListView can be selected while ItemsControl does not support selection.
– ListView is more feature rich, as it inherits ListBox, which inherits ItemsControl, and adds features.
– Make sure they understand what a DataGrid is and how it is different and why they would display a list in a DataGrid.
What can you do in Expression Blend that you cannot do in Visual Studio?
Configure brushes and gradient brushes in the Properties window.
Configure the Visual States.
Configure sample data.
Configure Object Timelines
Many design features…
What are some best practices when using WPF if you plan to build a Localized/Globalized application?
Write UI in XAML
Avoid sizing and positionings, but let objects automatically flow.
What the initial class that is loaded by any new WPF Application project?
The initial class loaded using WPF application project is
App.App.xaml and App.xaml.cs, even App is also acceptable.
Name some common Globalization/ Localization practices to Globalize/Localize WPF?
- Use a ResourceDictionary to manage localizable strings
- Use Resources.resx
- Use BAML