I am trying to make a custom groupstyle sector for my ListView as per other questions I've seen here on stack overflow.
public class TestGroupStyleSelector : GroupStyleSelector
{
protected override GroupStyle SelectGroupStyleCore(object item, uint level)
{
return (GroupStyle)App.Current.Resources["grpStyle"];
}
}
<ListView GroupStyleSelector="{StaticResource grpStyleSelector}">
I have two errors with this:
Error 1 'TestGroupStyleSelector': cannot derive from sealed type 'System.Windows.Controls.GroupStyleSelector'
Error 2 An object of the type "TestGroupStyleSelector" cannot be applied to a property that expects the type "System.Windows.Controls.GroupStyleSelector".
I have declared the class as other questions on here have shown, I am pretty lost at this point as to how to create a groupstyleselector for my listview, any ideas?
In WPF, using
<ListView GroupStyleSelector="{StaticResource grpStyleSelector}" />
and inheriting your selector from GroupStyleSelector will result in a 'cannot derive from sealed type 'System.Windows.Controls.GroupStyleSelector' exception.
Instead, use
<ListView>
<ListView.GroupStyle>
<GroupStyle ContainerStyleSelector="{StaticResource grpStyleSelector}" />
</ListView.GroupStyle>
</ListView>
and inherit your selector from StyleSelector
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With