Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SplitButton does not respect GroupStyle #2215

Closed
bloritsch opened this issue Nov 17, 2015 · 2 comments · Fixed by #2572
Closed

SplitButton does not respect GroupStyle #2215

bloritsch opened this issue Nov 17, 2015 · 2 comments · Fixed by #2572
Labels
Milestone

Comments

@bloritsch
Copy link

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);
    }
}
@bloritsch
Copy link
Author

Addendum, I also had to bind the ItemsPanel property:

BindingOperations.SetBinding(listBox, ItemsPanelProperty, new Binding
{
    Source = this,
    Path = new PropertyPath(ItemsPanelProperty)
});

@punker76
Copy link
Member

punker76 commented Jul 7, 2016

'GroupStyle' property is read-only and cannot be set from markup.

I'll add the template binding for the ItemsPanel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

2 participants