Frequently asked WPF interview questions 2019

WPF interview questions

WPF or Windows Presentation Foundation is a Graphic related task that displays user interfaces, images, movies, etc. Every year, .NET and such other interviews are held to fill up the vacancies with the good pay scale. This field is like the ocean where anything can be asked for the interview. Here, is a set of twenty questions that will give an idea of what to expect for your WPF interview. There is no less or more preparation for this particular interview. So, all you have to do is start with basics and then move on to the complex ones. These questions will help you understand the pattern of the interview that will get you mentally prepared for the big day. It’s not just about being physically prepared, but you have to be mentally prepared as well. So let’s start with questions and their answers that have a higher probability to be asked by the interviewer.

Download WPF interview questions PDF

WPF interview questions

When you want to represent a data in a hierarchical view, which is in a parent-child relationship and where a parent node can be collapsed or expanded than a TreeView is called into the scene.The left sidebar of Windows Explorer is a good example of the TreeView.A WPF TreeView control in XAML is represented by the TreeView tag.

In WPF, various properties are used while dealing with the content of content controls. The two properties are as follows:

Horizontal Content Alignment, and

Vertical Content Alignment

The parent class of all controls in WPF defines all the properties in System.Windows.Controls.Control class that is.
If we create a TextBox control and a UI with a Button, the UI looks like the following figure where the default vertical and horizontal alignment of the content of a Button is center. The default horizontal and vertical alignment of the content of a TextBox is left and top.

There are two types of resources:

  • Static resource
  • Dynamic resource

We should use the Static Resource markup extension to define the resource as a static resource. The value of Static Resource is determined at the time of loading.

Dynamic Resource is used in a situation where the value of the property needs to be changed at runtime.

Some of the possible options for the controls available are;

  • ItemsControl
  • ListBox
  • ListView
  • DataGrid

It is important to make sure that the ListView and ListBox can be selected when ItemsControl is not supporting a selection. You must also know that a ListView is more feature rich as it inherits ListBox that inherits ItemsControl and then adds features. You must also make sure that they understand the importance of DataGrid and how it is different from rest and why they must display a list in a DataGrid.

When you are planning to make applications in WPF, then you need framework named Model View View Model or MVVM. It is same as the MVC framework and has a 3-tier architecture with one more layer. We can do loose coupling using MVVM.

MVVM was originally introduced by John Gossman in the year 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 the implementation of an application uses different 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.

In WPF, templates are a very important part of user interface design. The three main types of templates of WPF are:

  • Items Panel Template
  • Control Template
  • Data Template

If you are planning to build a localized or globalized application.

  • You can write UI in XAML
  • Avoid positioning and sizing but lets the objects flow automatically
  • Enables text wrapping

WPF denotes Windows Presentation Foundation, which is a re-invention of a UI that uses WPF for Desktop applications. Just like other developers have been doing all this while, other than dropping controls on “Windows Forms,” WPF is known to provide an extra rapid boost to the application development including animation, Rich User Interface, and much more.

To summarise it all, following things can be done using WPF:

  • Draw Graphics and normal controls.
  • Transforming objects including controls, video, and shapes,
  • Can easily play/load video and audio files.
  • Can create and animate 3D graphics.
  • Can provide smooth graphical effects such as color gradients and drop shadows.
  • Can use shared styles which can be used across the same controls to provide the same theme, skin, and design.
  • Can easily be used to draw vector graphics that scale without jagged aliasing.

Advantages of WPF are:

  • Resolution independence
  • Tight multimedia integration
  • Hardware acceleration

Some common localization or globalization practices for localizing or globalizing WPF are:

1) Use Resources.resx,

2) Use BAML,

3) Use a Resource Dictionary to manage localizable strings.

In WPF, the AccessText control is used to convert a character that is preceded by an underscore to an Access Key. The Access Key is registered and therefore used to raise an event when pressed.

Prism is also known as Composite Application Guidance for WPF and Silverlight. It is a framework that can be used to build Silverlight apps and WPF. It has been designed to build solid applications in Silverlight and WPF that normally have a single code base. It is helpful in developing a client application, which is in a modular fashion. It is done so to divide large, complex applications into simple modules. The actual definition of a Prism being

Prism is developed by Microsoft Patterns and Practices and provides guidance designed to help you to more easily design and build rich, flexible and easy-to-maintain Windows Presentation Foundation (WPF) desktop applications.

it was initially called Prism but later on, Microsoft named it as ‘CompositeWPF’.

In AutoCAD, Polyline is an object, which consists of one or more than one line or arc in segments. To define it, a polyline is a collection of connected straight lines. The Polyline object represents a polyline shape and draws a polyline with the given points. The Points property represents the points in a polyline. The Stroke property sets the color and StrokeThickness represents the width of the line of a polyline.

A Value Converter is known to function as a bridge between a source and a target that is necessary when a target is bound with one source, for example, if you have a text box then you also has a button control. You want to disable or enable or disable the button control when the text of the text box is null or filled.

Sometimes the string data needs to be converted into Boolean. This is only possible when using a Value Converter. For implementing Value Converters, it requires you to inherit from I Value Converter in the System.Windows.Data namespace and then implement the two methods Convert Back and Convert.

You may note that in WPF, binding helps in the flow of data between the two WPF objects. The bound object that emits the data is called the Source, and the other (that accepts the data) is called the Target.

 Sometimes, there arises a need to perform the same activity, for that purpose WPF provides us with a feature called Command to make our work faster and easier. A Command is called on for several purposes. First of all, it is used to separate the semantics from the object that calls upon a command from the logic that executes a particular command.Commands are also used to share grouped actions inside an application in various ways.

There are mainly four types of Command:

  • Edit Commands
  • Application Commands
  • Media Commands
  • Component Commands

To blend expression in a Visual Studio

  • Configure visual states
  • Configure brushes and gradient brushes in the properties window
  • Configure object timelines
  • Configure sample data
  • Animation
  • And many other design features