CollectionView Not Collapsable

1 Answer 25 Views
CollectionView
Joe
Top achievements
Rank 1
Iron
Veteran
Iron
Joe asked on 19 Dec 2024, 08:08 PM

Hi,

I am trying to style a CollectionView to have groups, but I don't want the group to be collapsable, and I want to remove the indicator.

How would I style this?

Thanks

-Joe

1 Answer, 1 is accepted

Sort by
0
Accepted
Didi
Telerik team
answered on 20 Dec 2024, 08:29 AM

Hello Joe,

Let me get straight to the questions:

1) Cancel collapsing 

To cancel collapsing the groups you can use the GroupTapping event and in the event handler add e.Cancel = true;

    private void RadCollectionView_GroupTapping(object sender, Telerik.Maui.RadTappingEventArgs<Telerik.Maui.Controls.CollectionView.GroupContext> e)
    {
        e.Cancel = true;
    }

2) Remove the expand indicator:

Use the Groupstyling https://docs.telerik.com/devtools/maui/controls/collectionview/styling/group-style and set visibility to false to the ExpandCollapseIndicator

    <ContentPage.Resources>
        <ResourceDictionary>

            <Style x:Key="ExpandCollapseIndicatorStyle" TargetType="Label">
                <Setter Property="IsVisible" Value="False"/>
            </Style>
            
            <Style x:Key="GroupHeaderStyle" TargetType="telerik:RadCollectionViewGroupView">
                <Setter Property="ExpandCollapseIndicatorStyle" Value="{StaticResource ExpandCollapseIndicatorStyle}" />
                <Setter Property="BackgroundColor" Value="#C4E6E3" />
                <Setter Property="BorderColor" Value="#80CBC4" />
                <Setter Property="BorderThickness" Value="1" />
                <Setter Property="VisualStateManager.VisualStateGroups">
                    <VisualStateGroupList>
                        <VisualStateGroup Name="CommonStates">
                            <VisualState Name="Normal" />
                            <VisualState Name="PointerOver">
                                <VisualState.Setters>
                                    <Setter Property="BackgroundColor" Value="#D6EEEC" />
                                </VisualState.Setters>
                            </VisualState>
                        </VisualStateGroup>
                    </VisualStateGroupList>
                </Setter>
            </Style>
        </ResourceDictionary>
    </ContentPage.Resources>
    
    
    <telerik:RadCollectionView ItemsSource="{Binding Locations}"
                           GroupViewStyle="{StaticResource GroupHeaderStyle}"
                               GroupTapping="RadCollectionView_GroupTapping"
                           DisplayMemberPath="City">
        <telerik:RadCollectionView.BindingContext>
            <local:ViewModel />
        </telerik:RadCollectionView.BindingContext>
        <telerik:RadCollectionView.GroupDescriptors>
            <telerik:PropertyGroupDescriptor PropertyName="Country" />
        </telerik:RadCollectionView.GroupDescriptors>
    </telerik:RadCollectionView>

Regards,
Didi
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Joe
Top achievements
Rank 1
Iron
Veteran
Iron
commented on 20 Dec 2024, 04:16 PM

Thank you so much.  I figured it had to be straight forwad, but sometimes finding things in documentation is difficult.  This helps a lot.
Didi
Telerik team
commented on 21 Dec 2024, 11:44 AM

I am glad the suggested approaches were of help. Could you please share more details about the documentation and what is difficult to find? Customers feedback is important as it helps us improve our services, so if you have any feedback regarding the documentation, let me know. 
Tags
CollectionView
Asked by
Joe
Top achievements
Rank 1
Iron
Veteran
Iron
Answers by
Didi
Telerik team
Share this question
or