WPF interview question for experienced/WPF Interview Questions and Answers for Freshers & Experienced

Explain what is the use of property element syntax?

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

Posted Date:- 2021-09-20 05:52:20

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.

Posted Date:- 2021-09-20 05:45:39

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.

Posted Date:- 2021-09-20 05:44:54

What should a root element of an XAML document contain?

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

Posted Date:- 2021-09-20 05:44:17

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

Posted Date:- 2021-09-20 05:43:46

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 as Object Element Syntax.

Posted Date:- 2021-09-20 05:42:46

Explain what is Type Converter?

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

Posted Date:- 2021-09-20 05:42:14

What are the types of children does object element can have in XAML?

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

Posted Date:- 2021-09-20 05:41:27

How can you set a property attribute as a literal string and not a mark up extension?

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

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

Posted Date:- 2021-09-20 05:40:40

What are the various X: prefix 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.

Posted Date:- 2021-09-20 05:40:05

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

Posted Date:- 2021-09-20 05:39:03

Explain what is Markup extension 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 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.

Posted Date:- 2021-09-20 05:37:56

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

Posted Date:- 2021-09-20 05:37:15

In XAML how graphic components are specified?

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

For example,

* Tag with contents




* Tag without contents

< Button/>

Posted Date:- 2021-09-20 05:36:40

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

Displaying “Hello World.”

<page xmlns= '' ''>


Hello, World!



Posted Date:- 2021-09-20 05:35:42

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

Posted Date:- 2021-09-20 05:34:58

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

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

Posted Date:- 2021-09-20 05:34:03

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

Content Control

HeaderedContent Control

Items Control

HeaderedItems Control

Posted Date:- 2021-09-20 05:33:27

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.

Posted Date:- 2021-09-20 05:32:52

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.

Posted Date:- 2021-09-20 05:32:21

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.

Posted Date:- 2021-09-20 05:31:57

What does this command do and when would you use it?

It causes the any commands, such as a binding to Button.Command to check again if it can execute.
It is used when the command runs and the button should be enabled when the command completes, but the button stays disabled. This often occurs when running the command on a thread or by using a BackgroundWorker.

Posted Date:- 2021-09-20 05:31:14

Why is it better to use an IValueConverter instead of performing the conversion in the ViewModel?

This follows the Don’t Repeat Yourself (DRY) principle. It also follows the Single Responsibility Principle (SRP).
Because you may have to perform the same conversion between multiple View and ViewModel combinations. If each ViewModel has the code, the code is duplicated. If the code is in an IValueConverter, it exists in one place and is resusable.

Posted Date:- 2021-09-20 05:30:44

How do you implement binding a button click to a method?

Create a class that implements ICommand, often called RelayCommand or RoutedCommand.
Add an ICommand property to your ViewModel and instantiate the property using your ICommand implementation, RelayCommand or RoutedCommand.

Posted Date:- 2021-09-20 05:30:12

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.

Posted Date:- 2021-09-20 05:29:31

What is the use of a Dispatcher Object in WPF?

Almost every WPF element has thread affinity. This means that access to such an element should be made only from the thread that created the element. In order to do so, every element that requires thread affinity is derived, eventually, from DispatcherObject class. This class provides a property named Dispatcher that returns the Dispatcher object associated with the WPF element.

The Dispatcher class is used to perform work on his attached thread. It has a queue of work items and it is in charge of executing the work items on the dispatcher thread.

Posted Date:- 2021-09-20 05:28:50

What is the difference between style and resource in WPF?

A resource is used to target the properties of more than one type of control whereas style can define properties only for a single type of control at a time. And also we can define different styles as a part of one common resource.

Posted Date:- 2021-09-20 05:28:14

What is the difference between a Page and a Window in WPF when you are adding a new file in the Solution Explorer?

Pages are intended for use in Navigation applications (usually with Back and Forward buttons, e.g. Internet Explorer). Pages must be hosted in a NavigationWindow or a Frame.
Windows are just normal WPF application Windows, but can host Pages via a Frame container.

Posted Date:- 2021-09-20 05:27:51

Name some advantages of using WPF instead of Windows forms

Advantages of using WPF instead of Windows forms:

1. XAML makes it easy to create and edit your GUI, and allows the work to be split between a designer
2. (XAML) and a programmer (C#, VB.NET etc.).
3. It allows you to make user interfaces for both Windows applications and web applications (Silverlight/XBAP).
4. Databinding, which allows you to get a more clean separation of data and layout.
5. Uses hardware acceleration for drawing the GUI, for better performance.

Posted Date:- 2021-09-20 05:27:14

ListBox vs. ListView - what and when to choose for data binding?

A ListView is a specialized ListBox (that is, it inherits from ListBox). It allows you to specify different views rather than a straight list. You can either roll your own view, or use GridView (think explorer-like "details view"). It's basically the multi-column listbox, the cousin of windows form's listview.

If you don't need the additional capabilities of ListView, you can certainly use ListBox if you're simply showing a list of items (Even if the template is complex).

Posted Date:- 2021-09-20 05:26:21

How to globally catch exceptions in a WPF application?

Use the Application.DispatcherUnhandledException Event. Be aware that there'll be still exceptions which preclude a successful resuming of your application, like after a stack overflow, exhausted memory, or lost network connectivity while you're trying to save to the database.

Posted Date:- 2021-09-20 05:25:49

Does that mean WPF has replaced DirectX?

No, WPF does not replace DirectX. DirectX will still be still needed to make cutting edge games. The video performance of DirectX is still many times higher than WPF API. So when it comes to game development the preference will be always DirectX and not WPF. WPF is not an optimum solution to make games, oh yes you can make a TIC TAC TOE game but not high action animation.

Posted Date:- 2021-09-20 05:24:37

Does WPF build on top of Windows Forms or are they totally different?

These two are totally different technologies. They do offer some interoperability layers to both directions, but other than that have nothing in common. Windows Forms is more or less a lightweight wrapper on top of Win32/MFC, which means its extensibility in .NET is not that good in all cases. WPF is a new UI framework implemented from scratch. WPF is also much more flexible when it comes to customizing the existing types.

* WPF is better for cross platform development and creating 'flashy' GUI's. However it requires a newer .net framework than WinForms and requires a dx9 compatible GPU or higher (which most people will have).

* WinForms is still a powerful technology which can often be developed at a faster pace than WPF however, in the end, both technologies can be used to achieve the same thing. WinForms is commonly used to develop business applications whereas WPF is often used to create more end-user based bits of software, apps etc.

Posted Date:- 2021-09-20 05:23:55

Could you tell me what is the main differences between Style and ControlTemplate?

1. Styles set properties on controls.
2. ControlTemplate is a property shared by most controls that specify how they are rendered.

To elaborate, you can use a style to group settings for a bunch of properties so you can re-use that to standardize your controls. Styles can be set explicitly on controls or applied too all of a certain type.

Control Templates can be set by a style or set explicitly on a control to change the way it appears. All controls have default templates (and styles for that matter) that are embedded in the .net wpf assemblies.

Posted Date:- 2021-09-20 05:23:07

What is the correct syntax for binding to a property of a Singleton?

{Binding Source={x:Static sing:MySingletonClass.Instance}, Path=SomeProperty}

Posted Date:- 2021-09-20 05:22:09

Provide a situation in which you have or would use a ConverterParameter.

Any time you have a converter that returns something different based on a parameter.

Posted Date:- 2021-09-20 05:21:52

Can you explain the overall architecture of WPF?

* User32: It decides which goes where on the screen.
* DirectX: As said previously WPF uses directX internally. DirectX talks with drivers and renders the content.
* Milcore: Mil stands for media integration library. This section is a unmanaged code because it acts like a bridge between WPF managed and DirectX / User32 unmanaged API.
* Presentation core : This is a low level API exposed by WPF providing features for 2D , 3D , geometry etc.
* Presentation framework: This section has high level features like application controls , layouts . Content etc which helps you to build up your application.

Posted Date:- 2021-09-20 05:21:30

What is the Binding syntax for binding to a Static value?

{x:Static s:MyStaticClass.StaticValue2}

Posted Date:- 2021-09-20 05:20:45

Provide an example of when and why you would use MultiBinding.

When you have multiple values that your which to combine.

When you want to use String.Format in XAML.

Posted Date:- 2021-09-20 05:20:30

How do you bind a button’s Command property to a method?

You don’t. You bind to an ICommand. You create a class that implements ICommand and in that object you connect to your method.

Posted Date:- 2021-09-20 05:20:05

You want to use a custom Binding but the control does not support binding in the area you want. What are your options? Which would you choose and why?

Inherit object and add a Dependency Property – If the object is not sealed this is likely an easier option.

Create an attached property – The object might be sealed.

Posted Date:- 2021-09-20 05:19:46

How PresentationFramework assembly is used in WPF?

This assembly contains the UI controls like Label, TextBlock, TextBox, CheckBox, DataGrid, or ListView etc.

Posted Date:- 2021-09-20 05:17:53

Can you explain the complete WPF object hierarchy?

* Object: As WPF is created using .NET so the first class from which WPF UI classes inherits is the .NET object class.
* Dispatcher: This class ensures that all WPF UI objects can be accessed directly only by the thread who own him. Other threads who do not own him have to go via the dispatcher object.
* Dependency: WPF UI elements are represented by using XAML which is XML format. At any given moment of time a WPF element is surrounded by other WPF elements and the surrounded elements can influence this element and this is possible because of this dependency class. For example if a textbox surrounded by a panel, its very much possible that the panel background color can be inherited by the textbox.
* Visual: This is the class which helps WPF UI to have their visual representation.
* UI Element: This class helps to implement features like events, input, layouting etc.
* Framework element: This class supports for templating , styles , binding , resources etc.
And finally all WPF controls textbox , button , grids and whatever you can think about from the WPF tool box inherits from the framework element class.

Posted Date:- 2021-09-20 05:17:21

When should we use “x:name” vs “name” ?

There is no difference between “x:name” and “name” , “name” is short hand of “x:name”. But in classes where you do not find “name” property (this is a rare situations) we need to use “x:name” property.

Posted Date:- 2021-09-20 05:16:17

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.

Posted Date:- 2021-09-20 05:15:38

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.

Posted Date:- 2021-09-20 05:15:24

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.

Posted Date:- 2021-09-20 05:15:06

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.

Posted Date:- 2021-09-20 05:14:52

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.

Posted Date:- 2021-09-20 05:14: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 relatively to the bounded element.

Posted Date:- 2021-09-20 05:14:18

R4R Team
R4R provides WPF Freshers questions and answers (WPF Interview Questions and Answers) .The questions on R4R.in website is done by expert team! Mock Tests and Practice Papers for prepare yourself.. Mock Tests, Practice Papers,WPF interview question for experienced,WPF Freshers & Experienced Interview Questions and Answers,WPF Objetive choice questions and answers,WPF Multiple choice questions and answers,WPF objective, WPF questions , WPF answers,WPF MCQs questions and answers R4r provides Python,General knowledge(GK),Computer,PHP,SQL,Java,JSP,Android,CSS,Hibernate,Servlets,Spring etc Interview tips for Freshers and Experienced for WPF fresher interview questions ,WPF Experienced interview questions,WPF fresher interview questions and answers ,WPF Experienced interview questions and answers,tricky WPF queries for interview pdf,complex WPF for practice with answers,WPF for practice with answers You can search job and get offer latters by studing r4r.in .learn in easy ways .