WPF Interview Questions and Answers

WPF Interview Questions and Answers

Last updated on 19th Oct 2020, Blog, Interview Question

About author

Praveen (Sr Project Manager )

High level Domain Expert in TOP MNCs with 8+ Years of Experience. Also, Handled Around 20+ Projects and Shared his Knowledge by Writing these Blogs for us.

(5.0) | 12345 Ratings 2346

These WPF Interview Questions have been designed specially to get you acquainted with the nature of questions you may encounter during your interview for the subject of WPF . As per my experience good interviewers hardly plan to ask any particular question during your interview, normally questions start with some basic concept of the subject and later they continue based on further discussion and what you answer.we are going to cover top 100 WPF  Interview questions along with their detailed answers. We will be covering WPF  scenario based interview questions, WPF interview questions for freshers as well as WPF interview questions and answers for experienced. 

1. What is WPF?


WPF is the latest presentation API by Microsoft Windows. It is a 2D and 3D graphic engine. Its capabilities include:-

  • All the common user controls. For example, check boxes, buttons, sliders etc.
  • Supports flow and fix format documents
  • all the functionality of Flash and HTML
  • Data binding
  • Multimedia
  • Animation

2. What are the types of documents 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 presents content irrespective of the screen size.

 3. Name the namespace required for working with 3D?


The namespace required for working in 3D is System.Windows.Media.Media3D.

 4. Is it right to say that 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.

 5. What are dependency properties?


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

 6. How can the size of StatusBar be 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.

7. What are 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.

8. Why should WPF be 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.

9. How is Silverlight different from WPF browser applications?


 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.

10. Name the methods present in the DependencyObject?


 It has three objects, namely:

  • SetValue
  • ClearValue
  • GetValue

11. Write about PRISM?


PRISM is a framework for creating complex applications for WPF, Silverlight or Windows Phone. PRISM utilizes MVVM, IC, Command Patterns, DI and Separation of Concerns to get loose coupling.

12. Is it possible to 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.

13. Describe 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.

14. Name the common assemblies used in WPF?


  • PresentationFoundation
  • WindowsBase
  • PresentationCore

15. Define Path animations in WPF


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

Subscribe For Free Demo

Error: Contact form not found.

16. Can WPF applications be made without XAML?


Yes WPF applications can be created without XAML as using XAML in WPF is a matter of choice.

17. What are the types of windows in WPF?


WPF has three types of windows:

  • Normal Window
  • Page Window
  • Navigate Window

18. How can elements in a ListBox be 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));

19. How is MVVM different from 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.

20. Explain 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.

 21. How is System.Windows.Media.Visual dll utilized in WPF?


It is used whenever a requirement for creating a 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.

 22. What are the various layout panels in WPF?


They are:

  • Stack Panel
  • Grid Panel
  • Canvas Panel
  • Dock Panel
  • Wrap Panel

23. 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

24. 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.

25. What is the 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.

26. What are Attached Properties in WPF?


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

27. 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 the Model object is changed.

28. 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.

29. 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.

30. 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, DynamicResource is heavy on the system but it makes pages or windows load faster.

31. 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.

32. 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.

33. 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.

34. 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.

Course Curriculum

Learn Best WPF Training to Get Most In-Demand IT Skills

  • Instructor-led Sessions
  • Real-life Case Studies
  • Assignments
Explore Curriculum

35. 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.

36. 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 relative to the bounded element.

37. Explain Serialization?


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

38. Is MDI supported in WPF?


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

39. 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.

40. 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.

41. 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.

42. 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.

43. 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.

44. 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.

45. 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 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 where it originated.

46. 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.

 47. How to get Automation IDs of items in an 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.

48. 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.

49. State the name of the classes, which contain arbitrary content.


  • Content Control
  • HeaderedContentControl
  • Items Control
  • HeaderedItemsControl

50. Which NameSpace has ‘Popup’ and ‘Thumb’ controls?


The namespace system.windows.controls.primitives has ‘Popup’ and ‘Thumb’ controls.

51.Explain what XAML is?  What is the difference between XML and XAML?           


 XAML stands for eXtensible Application Markup Language. It is the language used to instantiate.NET objects.  It is the language developed by Microsoft to write user interfaces for next generation applications.

XML is designed to store data or to work with the stored data, whereas XAML is the extended version of XML used for.NET programming.

52.Mention the advantage of using XAML?


The advantage of using XAML is

  • XAML code is clear to read, and they are short
  • Separation of designer code and logic
  • Tools like expression blend used for graphical design require XAML as source
  • It clearly separates the roles of designer and developer
Course Curriculum

Get Best WPF Training Course from Expert Trainers

Weekday / Weekend BatchesSee Batch Details

53.How can you code to display “Hello World” in XAML?


 Displaying “Hello World.”

  • <page xmlns= ‘’ ‘’>
  • <TextBlock>
  • Hello, World!
  • </TextBlock>
  • </Page>

54.In XAML how graphic components are specified?


In XAML, graphic components are specified by open or closed tags with attributes.

For example,

Tag with contents

  • <Button>
  • Click
  • </Button>
  • Tag without contents
  • < Button/>

55.What is Attribute Syntax in XAML?


In XAML, attribute syntax sets a value for a property or names the event handler for an event, by declaring an attribute on an element.  The attribute value should be enclosed within two quotation marks (“).

For example,

  • < Button Background = “Black” Foreground “Red” Content = “This is an operating button”/>

 56.Explain Content Properties XAML?


XAML represents a language feature whereby a class can allot exactly one of its properties as XAML property

57.Explain what Markup extension is in XAML?


Markup extensions are placeholders in XAML that are used to resolve property at runtime. A markup extension allows you to extend XAML and using attribute syntax you can also set any property that can be set in XAML.The purpose of the markup extension is to process a string and return an object. Some of the standard markup extensions are xNull, x: Array, :StaticResource  and DynamicResource.

58.What are the four general kinds of XAML elements?


The four general kind of XAML elements are

  • Root Elements
  • Panel Elements
  • Control Elements
  • Geometric Elements

59.What X: prefix indicates in XAML?


The X: prefix is used to map the XAML namespace in templates.

60.What are the various X: prefixes used in XAML language?


  • x: Key à It sets a unique key for each resource in a Resource Dictionary
  • x: Classà It specifies the CLR ( Common Language Runtime) namespace and class name for the class that provides code
  • x: Name à It specifies a run-time object name for the instance that exist in run time code after an object element is processed
  • x: Static à It enables a reference that returns a static value which otherwise an XAML compatible property
  • x: Type à It constructs a Type reference based on the type name

61.How can you set a property attribute as a literal string and not a markup extension?


To avoid markup extension you have to use an empty pair of curly braces like

  • Content = “{} {This is not a markup extension}”/>

62.What are the types of children an object element can have in XAML?


Three types of children an object element can have

  • Collection Items
  • A value for the content property
  • The value that can be type-converted to the object element
Wpf Sample Resumes! Download & Edit, Get Noticed by Top Employers! Download

63.Explain what a Type Converter is?


 The type converter is helpful to convert a string into the appropriate value type where there is no markup extension usage.  Type Converter defines four members for converting to and from string for xaml purposes.

  • CanConvertTo
  • CanConvertFrom
  • ConvertTo
  • ConvertFrom

64.Explain Object Element Syntax in XAML?


To instantiate a CLR class or structure by declaring an XML element, an XAML markup syntax is used.  This syntax is referred to as Object Element Syntax.

65.What are the ways you can declare objects in XAML?


 To declare objects in XAML, there are three ways

  • Directly, using object element syntax: This syntax is used to declare root objects or nested objects that set property values
  • Indirectly by using attribute syntax: This syntax uses an inline string value which has an instruction on how to create an object. To set the value of the property to a newly created reference, the XAML parser uses this string
  • Using a markup extension

66.What should a root element of an XAML document contain?


In XAML documents, the root element consists only of certain elements, and these elements are Window, Canvas or panels.

67.What is data binding with XAML?


 Data binding provides a simple way to display and interact with data. An example will show how you can do data binding in XAML.  The binding in XAML is done by using {binding….} syntax.

68.Explain how you can display different data at run time and design time?


  • One way of displaying data at run time and design time is to declare your data in XAML.
  • Another way of doing it is by declaring it in XAML by using various data attributes from the designer XML namespace.  With a d: prefix, this namespace is typically declared.
  • xmlns: d= http://schemas.microsoft.com/expression/blend/2008

69.Explain what is the function x: Key directive in XAML?


 X: Key uniquely identifies elements that are created and referenced in an XAML defined dictionary. By adding an x: Key value to an XAML object element a resource in the resource dictionary can be identified and is the most common way to identify.

70.Explain what is the use of property element syntax?


 With the help of property element syntax, you can add children elements with a name in the form of parent.propertyName.

Are you looking training with Right Jobs?

Contact Us

Popular Courses