Skip to content

This repository contains the sample about how to keep one group in expanded state in Xamarin Forms ListView

Notifications You must be signed in to change notification settings

SyncfusionExamples/Keep-one-group-in-expanded-state-xamarin.forms-listview

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

Keeping only one group in expanded state

To keep any one specific group alone in the expanded state, use the SfListView.GroupExpanding event. 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.

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); 
    } 
 } 
}

To know more about grouping, please refer our documentation here

About

This repository contains the sample about how to keep one group in expanded state in Xamarin Forms ListView

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages