WPF interview questions

WPF Interview Questions and Answers

  • Tarun Natraj
  • 16th Aug, 2022

About WPF

WPF is one of the part of the Windows operating system. WPF helps to provide graphical user interfaces and environments for applications and services. They are developed and executed on Windows OS. WPF is a subsystem in the Windows operating system that appeared in the Windows Vista version. It is also a component of .NET framework 3.0, providing programming tool and technique for graphical development and the authoring of applications. WPF provides services such as support for extensible application markup language (XAML), 2-D and 3-D graphics, animation, styles, data binding and other graphical control elements essential for application developers.

WPF interview questions

1) What is WPF?

WPF (Windows Presentation Foundation) is a free and open-source graphical subsystem originally developed by Microsoft for rendering user interfaces in Windows-based applications. WPF was previously known as "Avalon", was initially released as part of .NET Framework 3.0 in 2006.

2) List Major advantages of using WPF?

Major advantages of WPF are

  • Easier animation and special effects
  • Inherent scalability
  • Tight multimedia integration
  • Hardware acceleration
  • Resolution independence
  • Easy deployment
  • Multimedia and animation with DirectX technology
  • HD video playback
  • Control rotation

3) What is a Prism in WPF?

Prism is a framework for building loosely coupled, maintainable, and testable XAML applications in WPF, and Xamarin Forms.

4) What is MVVM in WPF?

MVVM (Model-View-ViewModel) is a way of creating client applications that leverage core features of the WPF platform, allows for simple unit testing of application functionality, and helps developers and designers work together with less technical difficulties.

5) What is WPF TextBlock?

A TextBlock control in WPF provides a lightweight control for displaying small amounts of flow content. It is a lightweight text editor control for displaying and formattting small amount of text flow content.

Download Free : WPF interview questions PDF

6) What is the value converter in WPF?

A value converter is a class in WPF, that implements the simple interface IValueConverter with the two methods object Convert(object value) and object ConvertBack(object value). It is frequently used with data bindings and used bridge between a target and a source

7) What are dynamic and static resources in WPF?

Dynamic resources: Dynamic resources in WPF are the resources that you can manipulate at runtime and are evaluated at runtime. If your code behind changes the resource, the elements referring to resources as dynamic resources will also change.

Static resources: Static resources in WPF are the resources that you cannot manipulate at runtime. The static resources are evaluated only once by the element which refers to them during the loading of XAML.

8) What are different types of Command in WPF?

There are basically four types of Commands in WPF:

  • Application Commands: It includes File Level Commands. For Example File:-> Open
  • Edit Commands: It provides editing capabilities.
  • Component Commands: It provides a Scroll-up and Scroll-Down type of Command. It is also useful to move to the front of the section of text and move to the End.
  • Media Commands: It provides Multimedia type of commands like Play, Pause, etc

9) What is tree view in WPF?

A TreeView in WPF is a view that represents data in a hierarchical view in a parent-child relationship where a parent node can be expanded or collapsed. The left sidebar of Windows Explorer is an example of a TreeView. The TreeView tag represents a WPF TreeView control in XAML.

10) What is Virtualization in WPF?

Virtualization is a technique in WPF that improves the rendering performance of UI elements. By applying virtualization, the layout system ensures that only the visible items of a container are rendered on the screen.

Take Free: Wpf MCQ & Quiz

11) How to delete an item from tree view in WPF?

You can use TreeView.Items.Remove or TreeView.Items.RemoveAt method to delete an item from the collection of items in the TreeView. The RemoveAt method takes the index of the item in the collection.

12) Does WPF support MDI?

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

13) What do you understand by BAML 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.

14) Difference between DataContext and ItemsSource?

Difference between DataContext and ObjectDataProvider are

  • DataContext expects an object type where ItemsSource expects IEnumerable type objects.
  • DataContext is a dependency property is exposed by FrameworkElement base class,where as ItemsSource is defined by the ItemsControl class. All the descendants of FrameworkElement can utilize the DataContext property and set an object to its value. But we can only set a type of IEnumerable(or instance of class that derives from).
  • DataContext does not generate template, it only used to hold common data for other controls to bind. In terms of ItemsSource property, it is mainly used to generate template regardless of you set it in XAML or in the code behind.
  • DataContext is mainly used to hold common data that other child want to share. Thus it can be inherited by other child elements without problem. But for ItemsSource, it not used to share data in the visual tree. It is only valid for the element that defined. There is still one thing to be noted is that the child element can override the DataContext of the perent DataContext no mater directly or indirectly.

15) List different types of templates in WPF?

There are four types of templates available in WPF:

  • ControlTemplate.
  • DataTemplate.
  • ItemsPanelTemplate.
  • HeirarchialDataTemplate.

16) List types of documents supported by WPF?

WPF supports two types of major documents models which provide rich layout support for displaying large amounts of text combined with features like scrolling, pagination and zoom: The "Fixed Document" and the "Flow Document".

17) Which namespace required for working with 3D in WPF?

System.Windows.Media.Media3D Namespace is required for working with 3D in WPF. It supports support 3-D presentation and contains classes like AffineTransform3D, AmbientLight, AxisAngleRotation3D, ContainerUIElement3D, etc.

18) What are Freezable objects in WPF?

A Freezable Object is a special type of object that has two states: unfrozen and frozen. When unfrozen, a Freezable appears to behave like any other object. When frozen, a Freezable can no longer be modified.

A Freezable provides a Changed event to notify observers of any modifications to the object. Freezing a Freezable can improve its performance because it no longer needs to spend resources on-change notifications. A frozen Freezable can also be shared across threads, while an unfrozen Freezable cannot.

19) Explain DependencyObject in WPF?

The DependencyObject is a class in WPF that enables Windows Presentation Foundation (WPF) property system services on its many derived classes. The property system's primary function is to compute the values of properties and to provide system notification about values that have changed.

20) Name some core assemblies used in WPF?

The core assemblies used in WPF are:

  • WindowsBase.dll:- This is the core types constituting the infrastructure of WPF API.
  • PresentationCore.dll:- It defines numerous types of constituting the foundation of the WPF GUI layer.
  • PresentationFoundation.dll:- It defines WPF control types, animation & multimedia support, data binding support, and other WPF services.

21) What are Path animations in WPF?

A path animation is a type of AnimationTimeline that uses a PathGeometry as its input. Instead of setting a From, To, or By property (as you do for a From/To/By animation) or using keyframes (as you use for a key-frame animation), you define a geometric path and use it to set the PathGeometry property of the path animation. As the path animation progresses, it reads the x, y, and angle information from the path and uses that information to generate its output.

22) What is ICommand in WPF?

ICommand is an interface that is the code contract for commands that are written in .NET for Windows Runtime apps. These commands provide the commanding behavior for UI elements such as a Windows Runtime XAML Button and in particular an AppBarButton.

23) List types of windows in WPF?

There are three types of windows in WPF framework. They are

  • Navigate Window
  • Page Window
  • Normal Window

24) What are Routed events in WPF?

A routed event in WPF is a type of event that can invoke handlers on multiple listeners in an element tree rather than just the object that raised the event. It is basically a CLR event that is supported by an instance of the Routed Event class. It is registered with the WPF event system.

25) List various layout panels available in WPF?

WPF comes five built-in layout panels. They are

  • Canvas.
  • DockPanel.
  • Grid.
  • StackPanel.
  • WrapPanel.

26) Name some important subsystems in WPF?

Major subsystems of the WPF are:

  • Objects
  • Threading.DispatcherObject
  • Windows.DependancyObject
  • Windows.Media.Visuals
  • Windows.UIElements
  • Windows.FrameworkElement
  • Windows.Controls.Control

27) What are Attached Properties in WPF?

An attached property is intended to be used as a type of global property that is settable on any object. In Windows Presentation Foundation (WPF), attached properties are typically defined as a specialized form of dependency property that does not have the conventional property "wrapper".

28) What is WPF accesstext Control?

AccessText control in WPF is used to convert a character preceded by an underscore to an Access Key. The Access Key is registered and therefore raises an event when pressed.

29) What is an adorner?

An Adorner in WPF is a custom FrameworkElement that is bound to a UIElement. Adorners are rendered in an AdornerLayer, which is a rendering surface that is always on top of the adorned element or a collection of adorned elements.

30) What is serialization in WPF?

Serialization is a concept in which C# class objects are written or serialized to files. Serializing can be used to directly write the data properties of a class to a file.

31) What are style triggers?

A trigger in WPF basically enables you to change property values or take actions based on the value of a property. Style.Triggers is a property Trigger in WPF that enables you to specify triggers within your Style for styling and templating model.

32) What is winforms?

WinForms or Windows Forms is a free and open-source graphical (GUI) class library included as a part of Microsoft.

33) What is XBAP?

XBAP (XAML Browser Application) is a new Windows technology used for creating Rich Internet Applications. While windows applications are normally compiled to an .exe file, browser applications are compiled to an extension .xbap and can be run inside Internet Explorer.

34) What are Resources in WPF?

A resource in WPF is an object that can be reused in different places in your application. WPF supports different types of resources. These resources are primarily two types of resources: XAML resources and resource data files.

35) What is Command Design Pattern?

In object-oriented programming, the command design pattern is a behavioral design pattern in which an object is used to encapsulate all information needed to perform an action or trigger an event at a later time. This information includes the method name, the object that owns the method and values for the method parameters.

36) What is DockPanel Control in WPF?

WPF DockPanel is a standard layout control. It allows you to snap, or dock controls to the edges (top, bottom, right, left and center) of a rectangular area.

37) What is Trigger? List different types of triggers in WPF?

A trigger in WPF basically enables you to change property values or take actions based on the value of a property.Triggers are used to change the value of any given property, when certain conditions are satisfied. Triggers are usually defined in a style or in the root of a document which are applied to that specific control. There are mainly three types of triggers in WPF. They are

  • Property Triggers
  • Data Triggers
  • Event Triggers

38) What are different binding Modes in XAML?

There are five different binding Modes in XAML. They are

  • TwoWay Binding
  • OneWay Binding
  • OneWayToSource Binding
  • OneTime Binding
  • Default Binding

39) What are Control Template in WPF?

A template in WCF describes the overall look and visual appearance of a control. For each control, there is a default template associated with it which gives the control its appearance. There are two types of templates that are most commonly used in WCF they are Control Template and Data Template.

A Control Template in WPF defines the visual appearance of a control.

40) What is Rotate transform in WPF?

RotateTransform in WPF rotates an element clockwise by a specified angle about the point. The RotateTransform object in WPF represents RotateTransform. The Angle property represents the angle in degrees to rotate clockwise. The CenterX and CenterY properties represent the X and Y coordinates of the center point. By default, a ScaleTransform is centered at the point (0,0), which corresponds to the upper-left corner of the rectangle.

41) What is a Tab Control in WPF?

TabControl in WPF allows you to split your interface up into different areas, each accessible by clicking on the tab header, usually positioned at the top of the control. Tab controls are commonly used in Windows applications and even within Windows' own interfaces, like the properties dialog for files/folders, etc.

42) What is a Decorators class in WPF?

Decorator Class in WPF is a class that is defined in System.Windows.Controls namespace. It provides a base class for elements that apply effects onto or around a single child element, such as Border or Viewbox.

43) What are styles in WPF?

In WPF, you can think of a Style as a convenient way to apply a set of property values to multiple elements. You can use a style on any element that derives from FrameworkElement or FrameworkContentElement such as a Window or a Button.

WPF styles works just like CSS style, In the CSS we define styles for a control and we reuse the same where ever we need in the application

44) What is MilCore assembly in WPF?

MilCore assembly directly interacts with DirectX for rendering the visual system of WPF. Milcore is a part of the unmanaged code which allows tight integration with DirectX. All rendering of controls in WPF is done through DirectX engine.

45) What is CLR?

CLR is the basic and Virtual Machine component of the .NET Framework. It is the run-time enviornment in the .NET Framework that runs the codes and helps in making the development process easier by providing the various services.

Windows Presentation Foundation (WPF) provides a set of services that can be used to extend the functionality of a common language runtime (CLR) property.

1 comment(s) :

Leave A Comment :

Valid name is required.

Valid name is required.

Valid email id is required.