Interviewer And Interviewee Guide

Top WPF Interview Questions & Answers:

1. Explain the difference 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, DyanamicResource is heavy on the system but it makes pages or windows load faster.

2. What is 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.

3. Explain the 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.

4. List 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.

5. Which NameSpace has 'Thumb' and 'Popup' controls?

The namespace system.windows.controls.primitives has 'Popup' and 'Thumb' controls.

6. Which classes contain arbitrary content?

★ Content Control
★ HeaderedContent Control
★ Items Control
★ HeaderedItems Control

7. How to 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.

8. How you can 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.

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

10. Tell me 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.

Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.