Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

Explain path animation in WPF.

Answer»

In Path animations, an ANIMATED object follows a path set by a Path geometry. The PathGeometry property of the PathAnimation can be set by defining a geometric path. You can use path animations to animate objects along a complex path. A complex animation can be created by joining together straight lines, arcs, and Bezier curves in any order. 

Conclusion 

Microsoft's WPF is the best WAY to DEVELOP Windows-based applications, and that will likely continue to be true in the future. As of now, a lot of companies have heavily invested in the WPF infrastructure, so they are reluctant to invest in something else. Whether you are new to WPF architecture or have experience with it, you will need to keep certain basic concepts in mind before you GO to an interview. When you are interviewing for a software development job, employers will probably ask you several questions to DEMONSTRATE your WPF expertise. 

In this article, we have prepared a list of 30+ WPF interview questions that will help you prepare for your WPF interview. The answers to each question are based on extensive research and tailored to meet the expectations of the interviewer. 

Additional Useful Resources:

2.

Can you explain what is the Prism framework in WPF?

Answer»

Prism, also known as COMPOSITE Application Guidance/Library, is a framework that ENABLES you to design and develop rich, loosely coupled, flexible, testable, and easy-to-maintain desktop applications, Silverlight Rich INTERNET Applications (RIAs), and Windows Phone applications. Using modular development, the client application can be developed in a way that SIMPLIFIES the complexity of a large application. Applications built with Prism are composed of modules, which are reusable functional units that contain a portion of the application's overall functionality. As modules can be developed, tested, and deployed individually, cross-team DEPENDENCIES can be minimized, and team members can focus on specific aspects of a project.

Major Components of Prism:

  • Shell: It serves as a showcase for all modules. You can load all modules here.
  • BootStrapper: It is responsible for connecting the modules to Shell.
  • Modules: There are reusable functional units that can be developed independently. MVVM design patterns should be used to build these modules.

All the applications modules (A, B, C, and D as shown in the above diagram) are loaded in shell and the bootstrapper is responsible for connecting the modules to the shell.

3.

State difference between Silverlight and WPF Browser application.

Answer»

Microsoft offers two different products - Silverlight and Windows Presentation Foundation (WPF). These products differ in the following way: 

Silverlight WPF 
Silverlight is a Microsoft technology that develops rich WEB-based internet applications.  WPF is the latest development technology from Microsoft that ENABLES the development of enhanced graphics applications for Windows.  
It is usually regarded as a subset of WPF.   WPF is typically regarded as a subset of the .NET Framework.  
Rich Internet Applications (RIA) can be developed with Silverlight for web clients.   Rich Windows Graphical User Interfaces (GUIs) for Windows clients can be developed using WPF. 
Only DIRECT and bubble EVENTS can be handled by Silverlight.   There are three types of routed events supported by WPF (direct, bubbling, and tunneling).  
XmlDataProvider is supported by Silverlight, but not ObjectDataProvider. Both XMLDataProvider and ObjectDataProvider are supported by WPF. 
It does not support multibinding (taking multiple values and combining them into another value). It SUPPORTS multibinding.
4.

What do you mean by templates in WPF?

Answer»

WPF templates define the overall visual appearance and look of a control. There is always a default template associated with each control, which determines how it LOOKS. If you NEED to customize the visual behaviour of control or the visual appearance of it, you can easily create your own templates in WPF applications. Through data binding, the programming logic and the template can be connected. FOLLOWING is a list of four types of templates:   

  • Control Template: It enables you to customize a control's appearance and behavior.
  • Data Template: You can customize the look and feel of all your data objects with this.
  • ItemsPanel Template: This template allows you to customize the layout of items in ItemControls such as ListBoxes and ListViews.
  • HierarchalData Template: This template lets you customize the template of both the parent and child TREEVIEW items.
5.

Explain XAML in WPF and why do we need it?

Answer»

The Extensible Application Markup Language (XAML) by Microsoft is a new declarative programming language DESIGNED to create user INTERFACES for managed applications. WPF uses XAML to construct GUI (Graphical User Interface) for Windows applications. XAML is a markup language designed for creating user interfaces that look like XML (Extensible Markup Language).  XAML is optional (in TERMS of usage), but it serves as the core of the WPF UI design. 

Advantages of XAML-

  • Designing UI elements with XAML is another simple and easy task.
  • The purpose of XAML is to allow visual designers to directly design user interface elements.
  • In ADDITION to designing GUIs, it can also be used for other purposes, for example, to create workflows in Workflow Foundation.
  • With XAML, you can easily create, initialize, and specify properties for objects with hierarchical relationships.
  • Through XAML, WPF lets you control all visual aspects of the user interface.
  • Both bitmap and vector images are supported.
  • In XAML, visible UI elements can be created and separated from programming logic.
6.

Explain Rotate transform in WPF.

Answer»

Rotate transforms, as their name indicates, rotate an element around a specified angle. You can rotate a control, shape, or another element by certain degrees around a point by using the Rotate transform. In this WAY, you can create interesting user interfaces with both static and animated rotation. WPF provides a RotateTransform object that represents rotation. The Angle property indicates the degree of rotation in the clockwise direction. An element may also be rotated anticlockwise by setting a negative value. The X and Y coordinates of the center point are represented by the CenterX and CenterY PROPERTIES. By default, it uses the TOP leftmost corner of a given element as the center point and rotates it accordingly.  

Example: The FOLLOWING code creates two rectangles of equal size, but rotates the second rectangle by 45 degrees.

<Grid> <!-- Original Rectangle --> <Rectangle Width="200" Height="50" Fill="Yellow"/> <!-- Rectangle with 45 degrees rotation --> <Rectangle Width="200" Height="50" Fill="Blue" Opacity="0.5" Margin="61,27,117,184"> <Rectangle.RenderTransform> <RotateTransform CenterX="-50" CenterY="50" Angle="45" /> </Rectangle.RenderTransform> </Rectangle> </Grid>

As you can see in the following output, the second rectangle has been rotated by 45 degrees. 

7.

Explain Routed Events in WPF.

Answer»

Routed events are those that follow a specific routing strategy in order to move up or down the visual tree. Event handlers can be hooked up to the element that triggers the event or to multiple elements above and below it.


There are three main routing strategies for RoutedEvents, which are as follows:

  • Direct Event: An event triggered by a source element that MUST be handled by the source element itself. Direct events behave similarly to normal .NET events.
  • Bubbling Event: A bubble event begins with the element from where it was raised. AFTERWARDS, it navigates up to the top element (root) of the visual tree or until the event bubbles are stopped by marking it as handled. Typically, the top (root) element of WPF is a window.
  • Tunnel Event: The root element raises this event. Following that, it navigates down the visual tree to REACH the source element of the visual tree or until the TUNNELLING event is terminated by marking it as handled.
8.

What are Attached properties in WPF?

Answer»

An attached property is a concept in XAML (Extensible Application Markup Language). ESSENTIALLY, these properties ENABLE you to assign extra properties/values to any XAML element, even if it doesn't define them in its object model. As a special type of DependencyProperty, you can apply it to any DependencyObject to enhance the behavior of various controls and services. Attached properties would be useful in the following cases: 

  • When parent ELEMENTS iterate its child object and act UPON them in a certain way. Grid controls, for example, organize elements into ROWS and columns using its Grid.Row, Grid.RowSpan, Grid.Column and Grid.ColumnSpan attached properties.
  • When adding visuals to existing controls using custom templates.
  • The addition of generic features/services to existing controls, for example, ToolTipService and FocusManager. They are called attached behaviors.
9.

What are Dependency properties in WPF?

Answer»

WPF dependency properties are properties that extend the functionality of CLR (Common LANGUAGE Runtime) properties. Dependency properties are those whose value is dependent on external sources (value from other inputs), such as animation, data binding, styles, themes, and USER preferences, or visual TREE inheritance. These properties provide self-contained validation, default values, monitoring of changed properties, and other runtime information. 

Advantages of Dependency Property:

  • Dependency Property is not stored every time, but only when it is modified or changed. As a result, memory consumption is reduced.
  • The DependencyProperty is notified whenever a property's value changes via INotifyPropertyChange. As a result, data binding becomes simpler since changes are IMMEDIATELY reflected in the value.
  • Dependency Properties are capable of supporting animation, setting styles via style SETTERS, and even providing control templates.
10.

Can you explain value convertor in WPF?

Answer»

With WPF binding, you can bind two WPF UI objects and flow data between them. Objects emitting data are called sources, and objects accepting them are called targets.

ValueConverter is a piece of code that CONVERTS values from the source TYPE to the target type and back again, so you can databind PROPERTIES that have incompatible types. A value converter implements IValueConverter, a simple interface that provides two methods: Convert() and ConvertBack(). As a bridge between the source and target, WPF converters PROVIDE a way to convert data if the target and source have different data formats.

11.

Explain how MVVM (Model-View ViewModel) is different from MVC (Model-View Controller).

Answer»

MVVM and MVC differ in the FOLLOWING ways:

MVVM Pattern

MVC Pattern

MVVMMVC
A well-known architecture pattern for application development, MVVM stands for Model-View-ViewModel.   MVC stands for Model-View-Controller, the earliest Android application architecture.  
MVVM architecture consists of three main components: View, Model, and ViewModel. A MVC pattern consists of three main components: Model, View, and Controller.   
A model represents an object, a view represents the UI layer, and a viewmodel describes the connection between models and views. Models represent data, Views represent the UI, and Controllers deal with REQUESTS
Silverlight, AngularJS, and WPF all rely on MVVM.  Java springs and ASP.NET use MVC.   
The application is easy to modify. However, if the logic for data binding is too complex, it will make debugging the application a little more DIFFICULT.  Changing or modifying application features can be difficult due to the tight coupling of the code layers.
This architecture has the highest level of unit TESTABILITYA limited number of unit tests are supported. 
12.

What are the important features of MVVM?

Answer»

The following are some of the features of MVVM: 

  • MVVM allows your application architecture to be loosely coupled. A layer (Data layer, PRESENTATION layer, and domain layer) can be CHANGED independently of others.
  • The Model, ViewModel, and View layers can each be extended separately without IMPACTING the others.
  • One can write test cases for both the Model and ViewModel layers without referencing the View layer directly. As a result, it is easier to write unit test cases.
  • Enhanced system performance allows screens to load more quickly.
  • Code-behind files are not needed (MINIMALIST code-behind files).
  • It is possible for designers and developers to work together.
  • Streamline the workflow for designers and developers.
  • UI and BUSINESS layers are separated as views and viewmodels respectively.
  • Make complex WPF applications easier to develop.
13.

What do you mean by MVVM (Model View ViewModel)?

Answer»

MVVM (Model-View-ViewModel) is a pattern that is used extensively by the Windows Presentation Framework (WPF) for building applications. MVVM is not mandatory to create WPF applications, but knowing about it can simplify the process of building WPF applications. This method allows developers and designers to work together without a great deal of technical difficulty by utilizing the capabilities of the WPF platform. There are three main components of MVVM as shown below: 

  • View: Views represent the user interface components of WPF applications written in XAML. A number of controls are available, including user controls, buttons, and labels. There are also resources such as CONTROLTEMPLATE, DataTemplate, and Styles. Although the view may be entirely code-based, XAML will (and should) be used for a large proportion of the UI.
  • Model: In general, the model provides your application with the data it needs. Models implement the model for an application domain and also include business objects, validations, and backend objects for retrieving and storing data.
  • View Model: It is the interface between Views and Models, handling Presentation Logic as well as retrieving/saving data from the Models. In other words, it's an abstraction of a view in the application. ViewModels contain the logic that MANIPULATES the raw data so that it is displayed in views.

By calling the public methods in the Model classes, the ViewModel interacts with the Model. Model data is collected and sent to the View. Using WPF's data-binding and COMMAND features, the View interacts with the ViewModel. The ViewModel implements commands that are EXECUTED whenever a user interacts with the view. 

14.

Difference between WPF and Winforms.

Answer»
  • WinForms (Windows Forms): WinForms is Microsoft's GUI (Graphical User Interface) approach to the .Net Framework and was introduced in February 2002. It was the primary API for .NET used to build Windows applications until WPF and Silverlight were introduced. In order to develop a standalone application, only the runtime environment and OS (Operating system) are required.
  • WPF (Windows Presentation Foundation): In 2007, Microsoft introduced WPF to REPLACE WinForms in DESKTOP application development for the .Net Framework. WPF is a UI framework designed for creating Windows or desktop applications. Currently, it is the latest Windows presentation API.

Difference between WPF and Winforms:

WPFWinforms
It is the latest concept for building desktop/windows applications.  This is the old way to build desktop applications for Windows.  
A markup language is used to design the UI, allowing complex user interfaces to be designed. No markup language is used to design UI. Instead, event-driven controls are used. 
Comparatively to WinForms, it provides effective and fully supported data BINDING. In data binding, a connection is established between the application UI (User Interface) and the data that the application displays. Although it offers data binding, it does so in a limited way, so it's less effective than WPF.   
Besides providing 2D and 3D vector capabilities, it also offers functionality such as rich, interactive, animated, hardware-accelerated functions. In comparison to WPF, it does not provide rich, interactive, animated, hardware accelerated, vector 2D and 3D features.     
It is not easy to use WPF as it requires good knowledge of the controls.  When developing applications, Windows forms are more convenient. 
There is no limit to the customization of the UI, and the controls can be modified without difficulty since it is written from scratch.  It typically contains limited controls that are not easy to customize.  
This is an efficient approach when building an application that requires a variety of media types, creates a skinned user interface, binds to XML, and creates a desktop application that has a web-like navigation STYLEWhen you want to develop a simple application with few modern features and more resources online, it is considered good.
15.

State difference between WCF (Windows Communication Foundation) and WPF (Windows Presentation Foundation).

Answer»
  • WCF (Windows Communication Foundation): WCF is a Microsoft UNIFIED programming technology used for creating, configuring and deploying applications to a production environment for TESTING purposes. Developers can use it to create secure, reliable solutions that work across multiple platforms. It deals with the interoperability of distributed applications using the .NET framework. Learn More.
  • WPF (Windows Presentation Foundation): WPF is a new form of .NET technology developed by Microsoft that is used to build desktop applications and high-fidelity experiences for Windows. A comprehensive SET of built-in features are available in WPF, including controls, application model, data binding, layout, 2D and 3D graphics, animation, styles, templates, documents, resources, typography, etc., for application DEVELOPMENT.