- Home
- Forum
- Xamarin.Forms
- Sf Listview: Collapse all other groups when one is expanded
Sf Listview: Collapse all other groups when one is expanded
Hi,
As the title suggests , how can I collapse all but the selected group?
Thanks.
As the title suggests , how can I collapse all but the selected group?
Thanks.
SIGN IN To post a reply.
3 Replies
DB
Dinesh Babu Yadav
Syncfusion Team
May 8, 2017 08:29 AM UTC
Hi Customer,
Thank you for using Syncfusion Products.
Thank you for using Syncfusion Products.
We have checked the reported query “Need to Collapse all other groups when one group is expanded” at our end and we would like to let you know that the reported requirement can be achieved by using GroupExpanding event which will be triggered whenever a particular group is being expanded and the particular selected group can be get from GroupExpandCollapseChangingEventArgs by which you can compare and collapse all other groups and expand the particular selected group as highlighted in the below code snippets.
Code Example[C#]:
|
private void ListView_GroupExpanding(object sender, GroupExpandCollapseChangingEventArgs e)
{
if (e.Groups.Count > 0)
{
var group = e.Groups[0];
if (expandedGroup == null || group.Key != expandedGroup.Key)
{
foreach (var otherGroup in listView.DataSource.Groups)
{
if (group.Key != otherGroup.Key)
{
listView.CollapseGroup(otherGroup);
}
}
expandedGroup = group;
listView.ExpandGroup(expandedGroup);
}
}
} |
For your assistance we have prepared a working sample and you can download it from the below link.
Please let us know if you require further assistance.
Regards,
Dinesh Babu Yadav
AS
Anna Stuepp
April 9, 2019 08:16 AM UTC
Hello Dinesh. I used your approach but have a small problem with this.
Somehow whenever I use the .CollapseGroup() Command, it somehow hides all the Placeholder text I was displaying with Control.Text. This does not happen when collapsing and expanding the group by clicking on it.
Attachment: Example_Pictures_1d516259.zip
Somehow whenever I use the .CollapseGroup() Command, it somehow hides all the Placeholder text I was displaying with Control.Text. This does not happen when collapsing and expanding the group by clicking on it.
How can I prevent the disappearing of my placeholder?
Attachment: Example_Pictures_1d516259.zip
DB
Dinesh Babu Yadav
Syncfusion Team
April 10, 2019 05:21 AM UTC
Hi Anna,
We suspect that if your requirement is about to keep the Placeholder text visible even when group gets collapsed. If so, we would like to inform you that you need to place the placeholder inside GroupHeaderTemplate and also please ensure that you have defined the AllowGroupExpandCollapse as True to respond the gesture action on the group header item and expand/collapse the group at runtime.
Please refer our UG documentation sample for customizing GroupHeaderTemplate.
If above details doesn’t meet your requirement , please share more details regarding your use case in detail.
Regards,
Dinesh Babu Yadav
SIGN IN To post a reply.
- 3 Replies
- 3 Participants
-
BG bg
- May 5, 2017 06:17 AM UTC
- Apr 10, 2019 05:21 AM UTC