Wednesday, March 06, 2013

WPF Interview Questions?

Posted by Rahul Kharde at 7:21 AM
What is WPF?
WPF stands for Windows Presentation Foundation. It is an application programming Interface for developing rich UI on Windows API and WINfx. WPF is introduced in .NET 3.0. By the use of WPF we can
  • Capabilities to HTML and flash.
  • Has all equivalent common user controls like buttons, check boxes   sliders etc.
  • Fixed and flow format documents 
  • 2D and 3D dimensional  graphics 
  • Multimedia 
  • Data binding

What Is XAML?

XAML (Extensible Application Markup Language) is a XML based language used to create rich GUI’s.

  • It supports both vector and bitmap images
  • XAML is a new markup language which is used for defining UI elements and its relationships with other UI elements.
  • XAML is a XML document which defines objects and properties and WPF loads this document in actual memory.
  • Using XAML, you can create any kind of objects that means graphical or non-graphical.
  • XAML is a declarative XML-based language by which you can define object and properties in XML
  • XAML document is loaded by a XAML parser. XAML parser instantiates objects and set their properties. XAML describes objects, properties and there relation in between them. WPF parses the XAML document and instantiates the objects and creates the relation as defined by XAML.

What are the core WPF assemblies?

The core WPF assemblies are,
WindowsBase.dll:- This is the core types constituting the infrastructure of WPF API.

PresentationCore.dll:- It defines numerous types constituting foundation of WPF GUI layer.

PresentationFoundation.dll:- It defines WPF control types, animation & multimedia support, data binding support and other WPF services.

  Besides these three libraries WPF also uses an unmanaged binary called milcore.dll which acts as a bridge between WPF assemblies and DirectX runtime layer.

What are the types of triggers available in WPF?

Triggers define a list of setters that are executed if the specified condition is fulfilled. WPF knows three diferent types of triggers
  • Property Triggers get active, when a property gets a specified value.
  • Event Triggers get active, when a specified event is fired.
  • Data Triggers get active, when a binding expression reaches a specified value.
What is dependency property?

WPF elements are classes with methods, properties and events. Nearly every property of a WPF element is a dependency property. Dependency properties are used with databinding, animation, resources and styles.
Only a class that derive from base class DependencyObject can include dependency properties.

What is attached property in WPF?

These are dependency properties that belong to one class but can be used in another.

Consider the below code

<Rectangle Height="72" Width="131" Canvas.Left="74" Canvas.Top="77" />

Height and Width are regular properties of the Rectangle. But Canvas.Top and Canvas.
Left is dependency property as it belongs the canvas class. It’s used by the Rectangle to
specify its position within Canvas.

 

Readonly Dependency Properties

Some dependency property of WPF controls are readonly. They are often used to report the state of a control, like the IsMouseOver property. Is does not make sense to provide a setter for this value.

What is a Routed event?

In a typical WPF application, it contains many elements. These elements exist in an element tree relationship with each other. A routed event is a type of event that can invoke handlers on multiple listeners in an element tree, rather than just on the object that raised the event.
Routed events are events which navigate up or down the visual tree according to their RoutingStrategy.
You can hook up event handlers on the element that raises the event or also on other elements above or below it by using the attached event syntax: Button.Click="Button_Click". Routed events normally appear as pair. The first is a tunneling event called PreviewMouseDown and the second is the bubbling called MouseDown. They don't stop routing if the reach an event handler. To stop routing then you have to set e.Handled = true;

Tunneling The event is raised on the root element and navigates down to the visual tree until it reaches the source element or until the tunneling is stopped by marking the event as handeld. By naming convention it is called Preview... and appears before corresponding bubbling event.
Bubbling The event is raised on the source element and navigates up to the visual tree until it reaches the root element or until the bubbling is stopped by marking the event as handled. The bubbling event is raised after the tunneling event.
Direct The event is raised on the source element and must be handled on the source element itself. This behavior is the same as normal .NET events.

Which type of documents supported by WPF?
WPF supports two types of documents,
  • Fixed Format Documents
  • Flow Format Documents 
Fixed format document is like PDF. It displays contents regardless of screen resolution and size.
 
Flow format document adjust content with respect to screen resolution and size

What are the panels in WPF?

1.CANVAS - Explicitly positioning of controls
2.DOCKPANEL - Similar to windows form docking application
3.GRID - Can arrange child controls with rows and columns
4.STACKPANEL - Used to organize child controls either horizontally or vertically
5.WRAPPANEL - Can arrange child controls from left to right one after the other as long as they fit in to next line





If you enjoyed this post and wish to be informed whenever a new post is published, then make sure you subscribe to my regular Email Updates. Subscribe Now!


Kindly Bookmark and Share it:

YOUR ADSENSE CODE GOES HERE

0 comments:

Have any question? Feel Free To Post Below:

 

Popular Posts

Recent Comments

© 2011. All Rights Reserved | Help to understand .Net | Template by Blogger Widgets

Home | About | Top