*
Previous WPF-Question-Answers-21-30 C# Question Answers-1 - 10 Next

WPF (Windows Presentation Foundation) Question Answers - (31–40)

WPF Interview Questions (31 - 40)

31. What are the freezable objects?

A Freezable is a special type of object that has two states: unfrozen and frozen. When unfrozen, a Freezable behaves like any other object. When frozen, a Freezable can no longer be modified.

A Freezable provides a Changed event to notify observers of modifications. Freezing improves performance since change notifications are no longer needed, and frozen Freezables can be shared across threads (unfrozen ones cannot).

32. What are the layout controls in WPF?

Layout provides an ordered way to place UI elements and manage their size and position when resized. WPF layout controls:

  • Grid
  • DockPanel
  • Canvas
  • WrapPanel
  • UniformGrid
  • StackPanel

Each supports a different type of layout for its child elements.

33. What are the major subsystems of WPF?

  • Windows.Controls.Control
  • Windows.DependencyObject
  • Windows.FrameworkElement
  • Windows.Media.Visuals
  • Object
  • Threading.DispatcherObject
  • Windows.UIElements

34. What are the routing strategies in WPF?

Bubbling: Event handlers on the event source are invoked, then the event routes up the tree to parent elements until stopped or reaching the root. Raised after tunneling events.

Tunneling: Event starts at the root and travels down to the source element. Often prefixed with “Preview”.

Direct: Event is handled only by the source element, similar to standard CLR events, but supports class handling, EventSetter, and EventTrigger.

35. What are the VirtualizationModes of VirtualizingStackPanel?

Two modes:

  • Standard: Creates a container for each visible item and discards it when scrolled out of view.
  • Recycling: Reuses item containers instead of creating new ones. Better for performance with many items.
  <VirtualizingStackPanel Width="30" Height="200" VirtualizationMode="Recycling"/>
  

36. What are Triggers in WPF?

Triggers execute setters or actions when conditions are met (e.g., MouseOver, KeyDown). Types:

  • Property Triggers – active when a property has a specified value.
  • Event Triggers – active when an event fires.
  • Data Triggers – active when a binding expression reaches a specified value.
  • MultiTrigger / MultiDataTrigger – active when multiple conditions are met.

Changed properties revert when conditions are no longer satisfied. Triggers are ideal for transient states like IsPressed or IsSelected.

37. What are value converters in WPF?

Used in data binding when source and target types differ. Implement the IValueConverter interface:

  • Convert() – called when source updates target.
  • ConvertBack() – called when target updates source.

38. What is 2-pass System of layout controls? What is WPF 2-pass layout engine?

WPF uses a 2-pass layout cycle:

  1. Measure pass: determines desired size of each element.
  2. Arrange pass: explicitly sizes and positions elements.

39. What is an adorner?

A special FrameworkElement that provides visual clues or handles to elements. Adorners are bound to a UIElement and rendered on an AdornerLayer, above the adorned element. They give extra information or interaction affordances.

40. What is an attached property?

A property implemented by a parent control for use by child controls. Attached properties allow behaviors or values to be applied to child elements in XAML layouts.

Back to Index
Previous WPF-Question-Answers-21-30 C# Question Answers-1 - 10 Next
*
*