*
Previous WPF-Question-Answers-41-50 WPF-Question-Answers-81-90 Next

WPF (Windows Presentation Foundation) Question Answers - (51–60)

WPF Interview Questions (51 - 60)

51. What is Dependency Property In WPF?

Dependency properties are properties of classes that derive from DependencyObject, and they're special in that rather than simply using a backing field to store their value, they use some helper methods on DependencyObject. The value of a DependencyProperty is resolved dynamically when calling the GetValue() method that is inherited from DependencyObject. The value of a dependency property is not stored in a field of object, but in a dictionary of keys and values provided by the base class DependencyObject. The key of an entry is the name of the property and the value is the value you want to set.

Properties that belong to a specific class but can be used for another are called the dependency properties. These properties are set through methods such as, styling, data binding, animation, and inheritance.

52. What is DependencyObject?

DependencyObject—The base class for any object that can support dependency properties.

DependencyObject services and characteristics include the following:

  • Dependency property hosting support. You register a dependency property by calling the Register method, and storing the method's return value as a public static field in your class.
  • Attached property hosting support. You register an attached property by calling the RegisterAttached method, and storing the method's return value as a public static read-only field in your class.
  • Get, set, and clear utility methods for values of any dependency properties that exist on the DependencyObject.
  • Metadata, coerce value support, property changed notification, and override callbacks for dependency properties or attached properties.
  • A common base class for classes derived from ContentElement, Freezable, or Visual.

53. What is difference between Resource and style?

You can think of a Style as a convenient way to apply a set of property values to more than one element. WPF styling model is the separation of presentation and logic. Styles also can be inheritable using the 'BasedOn' property.

Styles and Resources: You can use a style on any element that derives from FrameworkElement or FrameworkContentElement. The most common way to declare a style is as a resource in the Resources section in a XAML file.

  <Style TargetType="TextBlock">
    <Setter Property="HorizontalAlignment" Value="Center" />
    <Setter Property="FontFamily" Value="Comic Sans MS"/>
    <Setter Property="FontSize" Value="14"/>
  </Style>
  

Because styles are resources, they obey the same scoping rules that apply to all resources.

54. What is Dispatcher in .NET?

Dispatcher class provides services for managing the queue of work items for a thread. It maintains a prioritized queue of work items for a specific thread.

When a Dispatcher is created on a thread, it becomes the only Dispatcher that can be associated with the thread. A Dispatcher is also created when you create a DispatcherObject.

In WPF, a DispatcherObject can only be accessed by the Dispatcher it is associated with. For example, a background thread cannot update the contents of a Button that is associated with the Dispatcher on the UI thread. This is accomplished by using either Invoke or BeginInvoke. Invoke is synchronous and BeginInvoke is asynchronous.

55. What is DispatcherObject?

DispatcherObject—The base class meant for any object that wishes to be accessed only on the thread that created it. Most WPF classes derive from DispatcherObject and are therefore inherently thread-unsafe.

56. What is FrameworkContentElement in WPF?

FrameworkContentElement—The analog to FrameworkElement for content.

57. What is FrameworkElement class in WPF?

FrameworkElement—The base class that adds support for styles, data binding, resources, and a few common mechanisms for controls, such as tooltips and context menus.

58. What is Freezable in WPF?

Freezable—The base class for objects that can be “frozen” into a read-only state for performance reasons. Freezables, once frozen, can be safely shared among multiple threads. Most Freezables are graphics primitives such as brushes, pens, geometries, or animation classes.

59. What is Globalization and Localization in WPF?

Globalization is the design and development of applications that perform in multiple locations. WPF provides globalized design features, including automatic layout, satellite assemblies, and localized attributes.

Localization is the translation of application resources into localized versions for the specific cultures that the application supports.

60. What is INotifyPropertyChanged in WPF?

INotifyPropertyChanged is an Interface from the namespace System.ComponentModel. It has an event “PropertyChanged” which fires when a property value changes. It is used to notify clients, typically binding clients.

Back to Index
Previous WPF-Question-Answers-41-50 WPF-Question-Answers-81-90 Next
*
*