In WPF (Windows Presentation Foundation), everything you see on screen is an object, and these objects form a logical hierarchy, which is often referred to as the WPF object hierarchy. This hierarchy defines how WPF elements are structured and how they relate to each other in a tree-like model called the visual tree and logical tree.
Let’s break down the key objects and their hierarchy:
🔶 1. System.Object
Top-most base class for all .NET types, including WPF classes.
Every class in WPF is derived from this.
🔶 2. DispatcherObject
Provides access to the WPF Dispatcher, which manages threading for UI elements.
All WPF objects that need to interact with the UI must be derived from this.
✅ Example: Button, Window, etc. can only be accessed on the UI thread via Dispatcher.
🔶 3. DependencyObject
Base for all objects that support Dependency Properties.
Enables property value inheritance, data binding, animations, styles, etc.
✅ Example: Width, Height, Margin, etc., are dependency properties.
🔶 4. Visual (and UIElement)
Visual: Represents drawing instructions (rendering), supports hit-testing, coordinate transformations.
UIElement: Adds input, focus, and event handling.
✅ Example: Enables layout, mouse events, keyboard input.
🔶 5. FrameworkElement
Adds support for layout (Margin, HorizontalAlignment, etc.), data binding, styles, resources.
Most WPF controls are derived from FrameworkElement.
✅ Example: TextBox, Grid, StackPanel, etc.
🔶 6. Control
Adds templating and user interaction logic.
Has Template, Style, and visual customization options.
✅ Example: Button, TextBox, ComboBox, etc.
🔶 7. Concrete Controls
These are the actual UI elements like:
- Button
- TextBox
- ListBox
- Window
- Grid
- etc.
Each of these inherits all the features from the chain above.
With tree Diagram
System.Object
└── DispatcherObject
└── DependencyObject
└── Visual
└── UIElement
└── FrameworkElement
└── Control
└── Button/TextBox/… etc.