According to the DispatherPriority enum, DataBinding
occurs before Rendering
.
- Send
- Normal - Constructors run here
- DataBind
- Render
- Loaded
- Background
- ContextIdle
- ApplicationIdle
- SystemIdle
- Inactive
- Invalid
- Input
So the binding would try to evaluate first before the render occurs.
However rendering can cause your binding to update, so if the process of rendering the parent panel would increase the width of the panel (for example, a parent panel placed inside of another panel that automatically stretches its children to take up 100% of the space like a Grid
or last element in a DockPanel
), then it will trigger an update on the binding and increase the width of the child during the render cycle.
The 2nd part of this SO answer may also help you understand. Take note of #6 too.
Sequence of events when a Window is created and shown
As requested, here is the sequence of major events in WPF when a window is created and shown:
Constructors and getters/setters are called as objects are created, including PropertyChangedCallback, ValidationCallback, etc on the objects being updated and any objects that inherit from them
As each element gets added to a visual or logical tree its Intialized event is fired, which causes Styles and Triggers to be found applied in addition to any element-specific initialization you may define [note: Initialized event not fired for leaves in a logical tree if there is no PresentationSource (eg Window) at its root]
The window and all non-collapsed Visuals on it are Measured, which causes an ApplyTemplate at each Control, which causes additional object tree construction including more constructors and getters/setters
The window and all non-collapsed Visuals on it are Arranged
The window and its descendants (both logical and visual) receive a Loaded event
Any data bindings that failed when they were first set are retried
The window and its descendants are given an opportunity to render their content visually
Steps 1-2 are done when the Window is created, whether or not it is shown. The other steps generally don't happen until a Window is shown, but they can happen earlier if triggered manually.