Skip to content

SplitButton does not respect GroupStyle #2215

@bloritsch

Description

@bloritsch

SplitButton extents ItemsCollection, which allows me to specify a GroupStyle (useful in configurations where I want to supply a set of standard static colors and a set of theme colors).

The "PART_ListBox" needs to bind the "GroupStyle" collection in SplitButton to the ListBox.GroupStyle collection. The short term work around was to subclass the SplitButton and override the OnApplyTemplate() call.

public override void OnApplyTemplate()
{
    base.OnApplyTemplate();

    // Can't use the EnforceType<ListBox> method in the base class because it's private.
    ListBox listBox = GetTemplateChild("PART_ListBox") as ListBox;

    if(listBox == null) { return; }

    foreach(GroupStyle style in GroupStyle)
    {
        listBox.GroupStyle.Add(style);
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions