Windows Presentation Foundation (WPF) Interview Questions And Answers

Download WPF Interview Questions and Answers PDF

Refine your WPF interview skills with our 57 critical questions. Each question is crafted to challenge your understanding and proficiency in WPF. Suitable for all skill levels, these questions are essential for effective preparation. Download the free PDF to have all 57 questions at your fingertips. This resource is designed to boost your confidence and ensure you're interview-ready.

57 WPF Questions and Answers:

WPF Job Interview Questions Table of Contents:

WPF Job Interview Questions and Answers
WPF Job Interview Questions and Answers

1 :: What is WPF?

Windows Presentation Foundation (WPF) is the presentation subsystem feature of the .NET Framework 3.0. It is pre-installed in as a part of Windows Vista, It is also available for installation on Windows XP SP2 and Windows Server 2003. It supports the rich User Experiences (UX) that have been made possible by advances in hardware and technology since the GDI based UI architecture was initially designed in the 1980's.
Read More

2 :: What is XBAP?

XBAP stands for XAML Browser Application. XBAP allows for WPF applications to be used inside a browser. The .NET framework is required to be installed on the client system. Hosted applications run in a partial trust sandbox environment. They are not given full access to the computer's resources and not all of WPF functionality is available.
Read More

3 :: What is XAML extensible markup language?

XAML is an extensible markup language based on XML. XAML can be thought of as a declarative script for creating .NET 3.0 UI. It is particularly used in WPF as a user interface markup language to define UI elements, data binding, eventing and other features. It is also used in Windows Workflow Foundation (WF), in which the workflows themselves can be defined in XAML code.
Read More

4 :: How can I enumerate all the descendants of a visual object?

You can enumerate all the descendants of a visual object as follows :

[C#]

// Enumerate all the descendants of the visual object.
static public void EnumVisual(Visual myVisual)
{
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(myVisual); i++)
{
// Retrieve child visual at specified index value.
Visual childVisual = (Visual)VisualTreeHelper.GetChild(myVisual, i);

// Do processing of the child visual object.

// Enumerate children of the child visual object.
EnumVisual(childVisual);
}
}
Read More

5 :: How can I create Custom Read-Only Dependency Properties?

The typical reason for specifying a read-only dependency property is that these are the properties that is used to determine the state, but where the state is defined in a multitude of factors. A typical example for a read-only property is IsMouseHover

This example shows how to 'register' an attached property as read-only. You can use dependency properties on any 'DependencyObject' types.

[C#]
public static readonly DependencyProperty IsBubbleSourceProperty = DependencyProperty.RegisterReadOnly(
"IsBubbleSource",
typeof(Boolean),
typeof(AquariumObject),
new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender)
);
Read More

6 :: How can I mark the default value of a custom dependency property to be false?

Here is an example :

[C#]

public class MyStateControl : ButtonBase
{
public MyStateControl() : base() { }
public Boolean State
{
get { return (Boolean)this.GetValue(StateProperty); }
set { this.SetValue(StateProperty, value); }
}
public static readonly DependencyProperty StateProperty = DependencyProperty.Register(
"State", typeof(Boolean), typeof(MyStateControl),new PropertyMetadata(false));
}
Read More

7 :: How can I set an attached property in code?

The following example shows how you can set an attached property in code.

[C#]

DockPanel myDockPanel = new DockPanel();
CheckBox myCheckBox = new CheckBox();
myCheckBox.Content = "Hello";
myDockPanel.Children.Add(myCheckBox);
DockPanel.SetDock(myCheckBox, Dock.Top);
Read More

8 :: How can I use an application resource?

The following example shows an application definition file. The application definition file defines a resource section (a value for the Resources property). Resources defined at the application level can be accessed by all other pages that are part of the application. In this case, the resource is a declared style. Because a complete style that includes a control template can be lengthy, this example omits the control template that is defined within the ContentTemplate property setter of the style.

[XAML]
<Application.Resources>
<Style TargetType="Button" x:Key="GelButton" >
<Setter Property="Margin" Value="1,2,1,2"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="Template">
<Setter.Value>

...

</Setter.Value>
</Setter>
</Style>
</Application.Resources>
Read More

9 :: List the types of documents which are supported by WPF?

Two types of the documents supported by Windows Presentation Foundation (WPF) are the Flow format and fixed Format document. Flow format document alters the content to fit the screen size while fixed format document present content irrespective of the screen size.
Read More

10 :: Define Freezable objects in WPF?

An object, which has its state locked down, so that it becomes unchangeable, is known as a freezable object. Such objects perform better. It is also safer if they are required to be shared between threads.
Read More

11 :: Is WPF has replaced DirectX?

No, WPF can never replace DirectX. WPF cannot be used to create games with stunning graphics. WPF is meant to be a replacement for windows form, not DirectX.
Read More

12 :: Explain the difference between Silverlight and WPF browser application?

One of the major differences is that .NET framework is required for running WPF browser applications on the client machine. But Silverlight runs using only the plug-in. Another point of difference is that applications made in WPF depend on the OS as .NET Framework only runs on Windows. On the other hand, the Silverlight plug-in can be installed on those OSs also, which are not Windows.
Read More

13 :: Which methods present in the DependencyObject?

It has three objects, namely:
★ SetValue
★ ClearValue
★ GetValue
Read More

14 :: How size of StatusBar increased proportionally?

By overruling the ItemsPanel attribute of StatusBar with a grid. The grid's columns can be appropriately configured to get the desired result.
Read More

15 :: Can we use Windows Forms in a WPF application?

Yes, Windows form can be used in WPF. Windows form can appear as a WPF pop. The controls of this Window form can be placed besides WPF controls in a WPF page by utilizing the functions of the WindowsFormsHost control that comes preinstalled.
Read More

16 :: Define CustomControl briefly?

CustomControl widens the functions of existing controls. It consists of a default style in Themes/Generic.xaml and a code file. It is the best way to make a control library and can also be styled or templated.
Read More

17 :: List the common assemblies used in WPF?

★ PresentationFoundation
★ WindowsBase
★ PresentaionCore
Read More

18 :: Why WPF preferred over Adobe Flash?

WPF is a more recent technology and thus has the latest development tools. It supports a broader range of programming languages and has a robust control reuse.
Read More

19 :: Described Path animations in WPF?

Path animation is a type of animation in which the animated object follows a path set by the Path geometry.
Read More

20 :: Described the purpose of dependency properties?

Properties that belong to a specific class but can be used for another are called the dependency properties.
Read More

21 :: List the types of windows in WPF?

WPF has three types of windows:
★ Normal Window
★ Page Window
★ Navigate Window
Read More

22 :: How elements in a ListBox sorted?

Sorting can be done by using a property of the ItemsCollection object. ItemsCollection contains an attribute, SortDescriptions, which holds System.ComponentModel.SortDescription instances. Every SortDescription instance defines how the elements should be sorted and indicates if the sort is descending or ascending.

For instance, this code sorts elements of ContentControl on the basis of their word count property:
myItemsControl.Items.SortDescriptions.Add(new SortDescription("WordCount", ListSortDirection.Descending));
Read More

23 :: Explain the difference between MVVM and MVC?

MVC stands for Model-View Controller and.MVVM stands for Model-View ViewModel.

In MVVM, View Model is used instead of a controller. This View Model is present beneath the UI layer. It reveals the command objects and data that the view requires. It acts like a container object from which view gets its actions and data.
Read More

24 :: How System.Windows.Media.Visual dll utilized in WPF?

It is used whenever a requirement for creating custom user interface arises. It is a drawing object, which gives instructions for making an object. These instructions include opacity etc. of the drawing. The Visual class also bridges the functionalities of WPF managed classes and the MilCore.dll.
Read More

25 :: Described routed events in WPF?

An event, which can invoke handlers on more than one listeners present in an element tree, instead of the single object which called the event, is known as a Routed event.
Read More