Windows Presentation Foundation(WPF) Interview Questions & Answers

  1. Question 1. What Is Xaml Namespace?

    Answer :

    Namespace can be defined as an environment or an abstract container used to hold a logical grouping of unique identifiers or symbols.

  2. Question 2. How Custom Classes Used In Xaml Can Be Defined?

    Answer :

    Custom classes are used in two ways:

    1. With the code that produces the Primary Windows Presentation Foundation (WPF) application or within the code behind.
    2. In a separate assembly as a class, such as an executable or DLL used as a class library.
  3. C#. NET Interview Questions

  4. Question 3. Explain What Is The Use Of Property Element Syntax?

    Answer :

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

  5. Question 4. Explain What Is The Function X: Key Directive In Xaml?

    Answer :

    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.

  6. C#. NET Tutorial

  7. Question 5. Explain How You Can Display Different Data At Run Time And Design Time?

    Answer :

    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=

  8. ASP.NET Interview Questions

  9. Question 6. What Is Data Binding With Xaml?

    Answer :

    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.

  10. Question 7. What Should A Root Element Of An Xaml Document Contain?

    Answer :

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

  11. ASP.NET Tutorial
    Advanced Dot Net Interview Questions

  12. Question 8. What Are The Ways You Can Declare Objects In Xaml?

    Answer :

    To declare objects in XAML, there are three ways:

    1. Directly, using object element syntax: This syntax is used to declare root objects or nested objects that set property values
    2. 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
    3. Using a markup extension.
  13. Question 9. Explain Object Element Syntax In Xaml?

    Answer :

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

  14. OOPS Interview Questions

  15. Question 10. Explain What Is Type Converter?

    Answer :

    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
  16. MVC Framework Tutorial

  17. Question 11. What Are The Types Of Children Does Object Element Can Have In Xaml?

    Answer :

    Three types of children an object element can have:

    1. Collection Items
    2. A value for the content property
    3. The value that can be type-converted to the object element
  18. MVC Framework Interview Questions

  19. Question 12. How Can You Set A Property Attribute As A Literal String And Not A Mark Up Extension?

    Answer :

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

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

  20. C#. NET Interview Questions

  21. Question 13. What Are The Various X: Prefix Used In Xaml Language?

    Answer :

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

  23. Question 14. What X: Prefix Indicates In Xaml?

    Answer :

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

  24. Question 15. What Are The Four General Kinds Of Xaml Elements?

    Answer :

    The four general kind of XAML elements are:

    1. Root Elements
    2. Panel Elements
    3. Control Elements
    4. Geometric Elements
  25. MVVM Interview Questions

  26. Question 16. Explain What Is Markup Extension In Xaml?

    Answer :

    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 mark up extension is to process a string and return an object. Some of the standard markup extensions are xNull, x: Array, :StaticResource  and DynamicResource.

  27. Windows Communication Foundation (WCF) Tutorial

  28. Question 17. Explain Content Properties Xaml?

    Answer :

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

  29. Windows Communication Foundation (WCF) Interview Questions

  30. Question 18. What Is Attribute Syntax In Xaml?

    Answer :

    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”/>

  31. ASP.NET Interview Questions

  32. Question 19. In Xaml How Graphic Components Are Specified?

    Answer :

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

    For example,
    Tag with contents

    Tag without contents
    < Button/>

  33. XAML Tutorial

  34. Question 20. How Can You Code To Display “hello World” In Xaml?

    Answer :

    Displaying “Hello World.”

    Hello, World!

  35. Dot Net Framework Interview Questions

  36. Question 21. Mention The Advantage Of Using Xaml?

    Answer :

    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
  37. Question 22. Explain What Is Xaml? What Is The Difference Between Xml And Xaml?

    Answer :

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

  38. Question 23. Which Namespace Has ‘popup’ And ‘thumb’ Controls?

    Answer :

    The namespace has ‘Popup’ and ‘Thumb’ controls.

  39. Advanced C# Interview Questions

  40. Question 24. State The Name Of The Classes, Which Contain Arbitrary Content?

    Answer :

    • Content Control
    • HeaderedContent Control
    • Items Control
    • HeaderedItems Control
  41. Advanced Dot Net Interview Questions

  42. Question 25. How Can Command-line Arguments Be Retrieved In A Wpf Application?

    Answer :

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

  43. Question 26. How To Get Automation Ids Of Items In A Itemscontrol?

    Answer :

    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.

  44. XAML Interview Questions

  45. Question 27. Why Is It Better To Wrap Items In Combobox Item?

    Answer :

    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.

  46. OOPS Interview Questions

  47. Question 28. What Are The Different Kinds Of Routed Events In Wpf?

    Answer :

    There are three types of Routed events in WPF.

    They are:

    1. Direct – This event can only be raised by the element in which it was originated.
    2. 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.
    3. 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.
  48. Question 29. Can Windows Service Be Created Using Wpf?

    Answer :

    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.

  49. Win32 Api Interview Questions

  50. Question 30. Where Does The Execution Start In A Wpf Application?

    Answer :

    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.

  51. Question 31. How Can Listbox Be Made To Scroll Smoothly?

    Answer :

    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.

  52. Question 32. How To Make A Tooltip Appear While Hovering Over A Disabled Element?

    Answer :

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

  53. Basic C Interview Questions

  54. Question 33. In What Sense Are Wpf And Silverlight Similar?

    Answer :

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

  55. MVC Framework Interview Questions

  56. Question 34. What Is Xbap?

    Answer :

    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.

  57. Question 35. Is Mdi Supported In Wpf?

    Answer :

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

  58. Question 36. Explain Serialization?

    Answer :

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

  59. MVVM Interview Questions

  60. Question 37. What Is An Adorner?

    Answer :

    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.

  61. Question 38. What Is The Unit Of Measurement In Wpf?

    Answer :

    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.

  62. Question 39. What Is The Way To Determine If A Freezable Object Is Frozen?

    Answer :

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

  63. Question 40. Write About Usercontrol In Brief.?

    Answer :

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

  64. Windows Communication Foundation (WCF) Interview Questions

  65. Question 41. Why Are Layout Panels Needed For In Wpf?

    Answer :

    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.

  66. Question 42. Explain Mvvm Pattern?

    Answer :

    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.
  67. Dot Net Framework Interview Questions

  68. Question 43. Write The Differences Between Dynamicresource And Staticresource.

    Answer :

    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

  69. Question 44. What Is The Method To Force Close A Tooltip, Which Is Currently Visible?

    Answer :

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

  70. Question 45. What Is The Basic Difference Between Events And Commands In The Mvvm Model?

    Answer :

    Commands are more powerful and are advantageous to use instead of events. Actions are deeply connected with the event 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.

  71. Question 46. What Is The Inotifypropertychanged Interface?

    Answer :

    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.

  72. Question 47. What Are Attached Properties In Wpf?

    Answer :

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

  73. Question 48. What Is Difference Between Page And Window Controls In Wpf?

    Answer :

    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.

  74. Question 49. What Does Baml Mean In Wpf?

    Answer :

    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.

  75. Question 50. Name The Important Subsystems In Wpf?

    Answer :

    The major subsystems are:

    • Windows.Controls.Control
    • Windows.DependancyObject
    • Windows.FrameworkElement
    • Windows.Media.Visuals
    • Object
    • Threading.DispatcherObject
    • Windows.UIElements
  76. Question 51. What Are The Various Layout Panels In Wpf?

    Answer :

    They are:

    • Stack Panel
    • Grid Panel
    • Canvas Panel
    • Dock Panel
    • Wrap Panel
  77. Question 52. How Is Dll Utilized In Wpf?

    Answer :

    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.

  78. Question 53. Explain Routed Events In Wpf?

    Answer :

    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.

  79. Question 54. How Is Mvvm Different From Mvc?

    Answer :

    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.

  80. Question 55. How Can Elements In A Listbox Be Sorted?

    Answer :

    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));

  81. Question 56. What Are The Types Of Windows In Wpf?

    Answer :

    WPF has three types of windows:

    • Normal Window
    • Page Window
    • Navigate Window
  82. Question 57. Can Wpf Applications Be Made Without Xaml?

    Answer :

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

  83. Question 58. Define Path Animations In Wpf?

    Answer :

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

  84. Question 59. Name The Common Assemblies Used In Wpf?

    Answer :

    • PresentationFoundation
    • WindowsBase
    • PresentaionCore
  85. Question 60. Describe Custom Control Briefly?

    Answer :

    Custom Control 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.

  86. Question 61. Is It Possible To Use Windows Forms In A Wpf Application?

    Answer :

    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.

  87. Question 62. Write About Prism?

    Answer :

    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.

  88. Question 63. Name The Methods Present In The Dependencyobject?

    Answer :

    It has three objects, namely:

    • SetValue
    • ClearValue
    • GetValue
  89. Question 64. How Is Silverlight Different From Wpf Browser Application?

    Answer :

    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.

  90. Question 65. Why Should Wpf Be Preferred Over Adobe Flash?

    Answer :

    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.

  91. Question 66. What Are Freezable Objects In Wpf?

    Answer :

    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.

  92. Question 67. How Can The Size Of Statusbar Be Increased Proportionally?

    Answer :

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

  93. Question 68. What Are Dependency Properties?

    Answer :

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

  94. Question 69. Is It Right To Say That Wpf Has Replaced Directx?

    Answer :

    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.

  95. Question 70. Name The Namespace Required For Working With 3d?

    Answer :

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

  96. Question 71. What Are The Types Of Documents Supported By Wpf?

    Answer :

    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.

  97. Question 72. What Is Wpf?

    Answer :

    WPF is the latest presentation API by Microsoft Windows. It is 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