Skip to content

Conversation

Nuklon
Copy link

@Nuklon Nuklon commented Jul 29, 2025

Pull request type

Please check the type of change your PR introduces:

  • Update
  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes

What is the current behavior?

Currently, a SplitButton has a mouseover/pressed color for the entire element. This isn't what WinUI does, it only changes this for the part hovered over (i.e., content and the toggle button).

New:
image
(only toggle has mouseover brush).
image
(only content has mouseover brush).

Old:
image
(entire button has mouseover brush).

@Nuklon Nuklon requested a review from pomianowski as a code owner July 29, 2025 10:04
@github-actions github-actions bot added controls Changes to the appearance or logic of custom controls. styles Topic is related to styles PR Pull request release labels Jul 29, 2025
@@ -72,22 +72,22 @@
<ControlTemplate TargetType="{x:Type controls:SplitButton}">
<Border
x:Name="ContentBorder"
Grid.Row="0"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't needed, there's no Grid, so I removed it as well.

@@ -115,10 +115,13 @@
Grid.Column="1"
VerticalAlignment="Center"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also added this so ContentTemplate can be used.

@Nuklon Nuklon changed the title Fix SplitButton not having separate brushes Fix SplitButton various issues Jul 29, 2025
@@ -42,7 +42,6 @@
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border
x:Name="ContentBorder"
Margin="0,-1,-1,-1"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This caused the toggle button to be off-center, there's no need for this, so just remove it.

@@ -134,7 +136,7 @@
Focusable="False"
Foreground="{TemplateBinding Foreground}"
IsChecked="{TemplateBinding IsDropDownOpen}"
Style="{StaticResource DefaultSplitButtonToggleButtonStyle}">
Style="{DynamicResource DefaultSplitButtonToggleButtonStyle}">
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we can override the style of the toggle button without having to redeclare the entire template.

Update SplitButton.xaml
private void AttachToggleButtonClick()
{
if (SplitButtonToggleButton != null)
{
SplitButtonToggleButton.Click -= OnSplitButtonToggleButtonOnClick;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This had to be changed to PreviewMouseLeftButtonUp for two reasons.

  1. If the Click event is used, there's hardly any visible Pressed state as it instantly presses.
  2. The SplitButton's context menu would immediately open on mouse down, this isn't the same in WinUI, where a mouse up is required.

@@ -85,29 +94,12 @@ public SplitButton()
};
}

protected virtual void AttachTemplateResources()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unused, so remove.

@github-actions github-actions bot added the ⭐ top pull request Top pull request. label Jul 30, 2025
@Nuklon Nuklon marked this pull request as draft July 30, 2025 08:47
@Nuklon Nuklon marked this pull request as ready for review July 30, 2025 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
controls Changes to the appearance or logic of custom controls. dotnet PR Pull request release ⭐ top pull request Top pull request. styles Topic is related to styles
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant