|
| 1 | +--- |
| 2 | +title: Hiding Default Expand Icon in .NET MAUI CollectionView with Grouping |
| 3 | +description: Learn how to hide the default expand icon in .NET MAUI CollectionView when grouping is used and use a custom icon instead. |
| 4 | +type: how-to |
| 5 | +page_title: Customizing Expand Icon in .NET MAUI CollectionView Grouping |
| 6 | +meta_title: Customizing Expand Icon in .NET MAUI CollectionView Grouping |
| 7 | +slug: hide-default-expand-icon-maui-collectionview-grouping |
| 8 | +tags: collectionview, expand-collapse-indicator, grouping, header-template, styling |
| 9 | +res_type: kb |
| 10 | +--- |
| 11 | + |
| 12 | +## Environment |
| 13 | + |
| 14 | +| Version | Product | Author | |
| 15 | +| --- | --- | ---- | |
| 16 | +| 11.1.0 | Telerik UI for .NET MAUI CollectionView | [Dobrinka Yordanova](https://www.telerik.com/blogs/author/dobrinka-yordanova)| |
| 17 | +## Description |
| 18 | + |
| 19 | +I want to hide the default expand/collapse icon in the .NET MAUI CollectionView when grouping is used. I plan to use a custom icon and style it further. |
| 20 | + |
| 21 | +This knowledge base article also answers the following questions: |
| 22 | +- How can I replace the default expand icon in .NET MAUI CollectionView with a custom one? |
| 23 | +- How to hide the expand/collapse indicator in .NET MAUI CollectionView grouping? |
| 24 | +- How to style the expand/collapse icon in .NET MAUI CollectionView? |
| 25 | + |
| 26 | +## Solution |
| 27 | + |
| 28 | +To hide the default expand/collapse icon and use a custom icon, use either the [`GroupViewStyle` property](#option-1-using-groupviewstyle) or [remove the default indicator](#option-2-removing-default-indicator). |
| 29 | + |
| 30 | +### Option 1: Using `GroupViewStyle` |
| 31 | + |
| 32 | +1. Remove the default expand arrow from the group template. |
| 33 | +2. Use the `GroupViewStyle` property and its `ExpandCollapseIndicatorStyle` to style the expand indicator. |
| 34 | + |
| 35 | +```XAML |
| 36 | +<telerik:RadCollectionView.GroupViewStyle> |
| 37 | + <telerik:GroupViewStyle ExpandCollapseIndicatorStyle="{StaticResource ExpandCollapseIndicatorStyle}" /> |
| 38 | +</telerik:RadCollectionView.GroupViewStyle> |
| 39 | +``` |
| 40 | + |
| 41 | +3. Define the style with the target type `Label`. |
| 42 | + |
| 43 | +```XAML |
| 44 | +<Style x:Key="ExpandCollapseIndicatorStyle" TargetType="Label"> |
| 45 | + <Setter Property="TextColor" Value="Black" /> |
| 46 | + <Setter Property="FontSize" Value="18" /> |
| 47 | +</Style> |
| 48 | +``` |
| 49 | + |
| 50 | +Refer to the official documentation for more information on [GroupViewStyle](https://www.telerik.com/maui-ui/documentation/controls/collectionview/styling/group-style). |
| 51 | + |
| 52 | +### Option 2: Removing Default Indicator |
| 53 | + |
| 54 | +1. Set the `IsVisible` property of the expand/collapse indicator to `False` in the style. |
| 55 | + |
| 56 | +```XAML |
| 57 | +<Style x:Key="ExpandCollapseIndicatorStyle" TargetType="Label"> |
| 58 | + <Setter Property="TextColor" Value="Black" /> |
| 59 | + <Setter Property="IsVisible" Value="False" /> |
| 60 | +</Style> |
| 61 | +``` |
| 62 | + |
| 63 | +2. Define your custom indicator in the group template. |
| 64 | + |
| 65 | +```XAML |
| 66 | +<telerik:RadCollectionView.GroupViewStyle> |
| 67 | + <telerik:GroupViewStyle ExpandCollapseIndicatorStyle="{StaticResource ExpandCollapseIndicatorStyle}" /> |
| 68 | +</telerik:RadCollectionView.GroupViewStyle> |
| 69 | +``` |
| 70 | + |
| 71 | +## See Also |
| 72 | + |
| 73 | +- [Grouping in CollectionView](https://www.telerik.com/maui-ui/documentation/controls/collectionview/grouping/overview) |
| 74 | +- [CollectionView GroupViewStyle](https://www.telerik.com/maui-ui/documentation/controls/collectionview/styling/group-style) |
| 75 | +- [Customizing Group Header Text Area](https://www.telerik.com/maui-ui/documentation/controls/collectionview/grouping/header#customizing-the-area-with-the-group-header-text) |
0 commit comments