fix(controls): Fix Separator layout and add Orientation attached prop… #1630
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull request type
Please check the type of change your PR introduces:
What is the current behavior?
Currently, the Separator control uses a global implicit style to apply WPFUI’s theme colors and attempts to support vertical orientation. However, several issues cause incorrect layout behavior:
"Double Margin" Effect: The implicit style overrides the default template and incorrectly makes the internal Border's Margin property inherit the Separator control's Margin property via TemplateBinding.
As shown below:
This causes the Separator's own Margin property to take effect, and the internal Border also inherits the same Margin value. The Border then creates spacing inside the control, expanding it and ultimately manifesting as a "double margin" effect.
Example:

Directional Support: It uses the Top and Left borders of a Border to simulate horizontal and vertical separator lines. When width or height is set larger than 1, two lines become visible. Moreover, these lines are not centered—unlike the native WPF Separator, whose line always stays in the middle.
Example:

<Separator Width="100" Height="100" />Property and Resource Key Naming: Due to the above design (using Border to draw the line), the style uses
BorderBrushfor theming, and the resource key is named “SeparatorBorderBrush.” However, the native WPF Separator uses theBackgroundproperty for its visual color. This discrepancy can confuse developers and lead to unexpected behavior.Issue Number: N/A
What is the new behavior?
The style has been redefined to align with the behavior of the native WPF Separator control, eliminating the “double margin” issue.
Introduced the
SeparatorAttachedhelper class, which adds anOrientationattached property to Separator. Together with the updated style, this enables seamless direction switching.Renamed the theme resource key from SeparatorBorderBrush to SeparatorBackgroundBrush, matching WPF’s native naming pattern and unifying developer expectations.
Examples:
and:
Other information