Latest WPF Interview Questions and Answers

Read Top WPF Interview Questions and Answers Experienced, Freshers for Job Interview Quiz with Solutions.

Name the important subsystems in WPF

The major subsystems are:

  • Windows.Controls.Control

  • Windows.DependancyObject

  • Windows.FrameworkElement

  • Windows.Media.Visuals

  • Object

  • Threading.DispatcherObject

  • Windows.UIElements

What does BAML mean in WPF?

BAML is the abbreviation for Binary Application Markup Language. It is nothing but XAML that has been tokenized, parsed and changed into binary form. BAML is a compressed declarative language, which gets loaded and parsed quicker than XAML.

What is Difference between Page and Window Controls in WPF?

The basic difference is that Window Control presides over Windows Application while Page Control presides over the hosted Browser Applications. Also, Window control may contain Page Control, but the reverse cannot happen.

What are Attached Properties in WPF?

Attached properties are basically Dependency Properties that allows the attachment of a value to any random object.

What is the INotifyPropertyChanged Interface?

The InotifyPropertyChanged notifies clients, generally those who are binding, if the value of a property gets changed. It has an event, called PropertyChanged, which gets raised everytime a property of Model object is changed.

What is the basic difference between Events and Commands in the MVVM Model?

Commands are more powerful and are advantageous to use instead of events. Actions are deeply connected with the event’s source and, therefore, the events cannot be reused easily. But commands make it possible to efficiently maintain multiple actions at one place and then reuse them as per our requirement.

What is the method to force close a ToolTip, which is currently visible?

It can be closed by setting the tooltip’s IsOpen property to false.

Write the differences between DynamicResource and StaticResource.

The most basic difference is that StaticResource evaluates the resource one time only, but DynamicResource evaluates it every time the resource is required. And due to this reason, DyanamicResource is heavy on the system but it makes pages or windows load faster


Explain MVVM pattern.

MVVM pattern divides the UI code into 3 basic parts:

  • Model – It represents a set of classes, which contain data received from databases.

  • View – It is the code that agrees with the visual representation of the data.

  • ViewModel – It is the layer that binds View and Model together. It presents this data in a manner, which is easy to understand. It also controls how View interacts with the application.

Why are layout panels needed for in WPF?

Layout Panels are needed so that the controls fit screens of different sizes or having different font sizes. If we arrange controls on fixed pixel coordinates, then this model will fail when moved to a different environment. For this reason, Layout panels are necessary.

Write about UserControl in brief.

UserControl wraps existing controls into a single reusable group. It contains a XAML file and a code. UserControl cannot be styled or templated.

What is the way to determine if a Freezable object is Frozen?

“IsFrozen” property of the object can be used to determine if the freezable object is frozen.

What is the unit of measurement in WPF?

All measurements are made in device-independent pixels, or logical pixels. One pixel is 1/96th part of an inch. These logical pixels are always mentioned as double, this enables them to have a fractional value too.

What is an adorner?

They are a special kind of FrameworkElement that provide visual clues to the user. They are also used to add handles to elements and give information about the state of a control. Adorners are bound to the UIElement and are rendered on a surface that lies above the element, which is adorned. This surface is called an AdornerLayer. Adorners are mostly placed relatively to the bounded element.


Explain Serialization?

It is the process of converting the state of an object to stream of bytes.

Is MDI supported in WPF?

MDI is not supported in WPF. UserControl can be used to give the same functionality as MDI.

What is XBAP?

XBAP is the abbreviated form of XAML Browser Application. It allows WPF applications to run inside web browsers. Installation of .NET framework on the client machine is a prerequisite for running WPF applications. But hosted applications are not given full admission to the client’s machine and are executed in a sandbox environment. Using WPF, such applications can also be created, which run directly in the browser. These applications are called XBAP.

In what sense are WPF and Silverlight similar?

Silverlight and WPF are similar in the sense that they both use XAML and share the same code, syntax and libraries.

How to make a ToolTip appear while hovering over a disabled element?

For this purpose, the ShowOnDisabled property can be used. It belongs to the ToolTipService class.

How can ListBox be made to scroll smoothly?

ListBox is configured to scroll on an item-by-item basis by default. This is dependent on the height of each element and the scrolling action, thus, giving a rough feeling. Better way is to configure scrolling action so that it shifts items by a few pixels irrespective of their height. This is done by setting the ScrollViewer.CanContentScroll property to “false”. This will, however, make the ListBox lose the virtualization property.

Where does the execution start in a WPF application?

WPF applications created in Visual Studio run without a Main method. This is because the applications are special-cased when they are compiled from XAML. That means, Visual Studio attaches a Build Action of ApplicationDefinition to the XAML file. This results in the auto generation of a Main method.

Can Windows Service be created Using WPF?

No, Windows Services cannot be created using WPF. WPF is a presentation language. Windows services need specific permissions to execute some GUI related functions. Therefore, if it does not get the required permissions, it gives errors.

What are the different kinds of Routed events in WPF?

There are three types of Routed events in WPF. They are:

  • Direct – This event can only be raised by the element in which it was originated.

  • Tunneling – This event is first raised by the element in which it was originated and then it gets raised by each consecutive container in the visual tree.

  • Bubbling – This event is first raised by the uppermost container in the visual tree and then gets raised by each consecutive container lying below the uppermost one, till it reaches the element it where it was originated.

Why is it better to wrap items in ComboBoxItem?

It has some important properties like IsSelected and IsHighlighted and also some necessary events like Selected and Unselected. ComboBoxItem is a content control and is thus very useful for adding simple strings to a ComboBox.

How to get Automation IDs of items in a ItemsControl?

The best way to do this is by setting it Name property as it is utilized for automation purposes by default. But if you require to give an ID to an element, other than it’s name, then the AutomationProperties.AutomationID property can be set as per need.


How can command-line arguments be retrieved in a WPF application?

The most preferred method for this is to call System.Environment.GetCommandLineArgs at any random point in the application.



Popular posts from this blog

TOP Agile Testing Interview Questions and Answers

Latest Agile Testing Interview Questions and Answers

Most Asked ADO.NET Interview Questions and Answers