| WPF-Question-Answers-21-30 | C# Question Answers-1 - 10 | |
WPF (Windows Presentation Foundation) Question Answers - (31–40) |
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).
Layout provides an ordered way to place UI elements and manage their size and position when resized. WPF layout controls:
Each supports a different type of layout for its child elements.
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.
Two modes:
<VirtualizingStackPanel Width="30" Height="200" VirtualizationMode="Recycling"/>
Triggers execute setters or actions when conditions are met (e.g., MouseOver, KeyDown). Types:
Changed properties revert when conditions are no longer satisfied.
Triggers are ideal for transient states like IsPressed or IsSelected.
Used in data binding when source and target types differ.
Implement the IValueConverter interface:
WPF uses a 2-pass layout cycle:
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.
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.
| WPF-Question-Answers-21-30 | C# Question Answers-1 - 10 | |