question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add Collapse Support to ListViewGroup

See original GitHub issue

Is your feature request related to a problem? Please describe.

As of now, there’s not an option for a user to hide items under a ListViewGroup that they aren’t interested in seeing at the time, similar to what windows like File Explorer provide. This could result in endless scrolling if there are many ListViewGroups and many items under each group. As #2623 suggested, a collapsible/collapse property would be a nice touch to give users flexibility and can especially be useful for clutter management purposes.

Describe the solution you’d like

Add the ability for users to make items in a group collapsible.

API:

public class ListViewGroup 
{
    public bool Collapsible { get; set; }
    public bool Collapsed { get; set; }
}

Example:

var lvGroup = new ListViewGroup 
{
    Collapsible = true,
    Collapsed = false
};

An excellent visualization of what this might look like from the original issue: image

Will this feature affect UI controls?

Yes.

Will VS Designer need to support the feature? It would be nice. I would imagine the Designer would have an area carved out in the ListViewGroup Collection Editor where Collapsible/Collapsed can be toggled. Something like so: designerex

I also imagine that the changes would immediately visible to the user in the designer, again similar to what is shown in the original issue.

What impact will it have on accessibility? I’m not quite sure here.

Will this feature need to be localized or be localizable? Aside from some work relating to accessibility namely perhaps what a talkback would use to describe the property, no I do not think this needs to be localized/localizable.


Update After implementing Collapsible/Collapsed property for ListViewGroup as done so in #3155 , we realize that this will be an issue with the design-time serializer, which orders properties assignment statement alphabetically. This means that Collapsed will come before Collapsible. Suppose a user wanted to set the properties like so in designer: image The serializer will generate:

this.listViewGroup1.Collapsed = true;
this.listViewGroup1.Collapsible = true;

Since Collapsed is no-op when Collapsible = false (which is the default), the end result will be Collapsed = false and Collapsible = true , not what the user intended.

Suggestion Upon discussion with the team, we came to the idea to merge the two properties into one. The new API will be as follows:

public class ListViewGroup 
{
    public enum ListViewGroupCollapsedState 
    {
        DEFAULT,
        EXPANDED,
        COLLAPSED
    }

    public ListViewGroupCollasedState CollapsedState { get; set; }
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
RussKiecommented, Apr 23, 2020

I’ve scanned the neighbouring API and the ListView et al API have the following public surface:

so the proposal to add the following fits right in:

  • bool ListViewGroup.Collapsible
  • bool ListViewGroup.Collapsed.

It should be noted that TreeNode appears to favour IsXyz naming convention, that feels inconsistent for the current context:

I believe we should follow the former naming than the latter.

1reaction
weltkantecommented, Apr 16, 2020

What impact will it have on accessibility?

It will be needed to be presented though accessibility API that you can toggle the collapsed state of a group.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - ListView hide or collapse selected group
It seems that the .NET version of the ListViewGroup class does not provide a Collapse or Expand method. Luckily, the native ListView control ......
Read more >
ListViewGroup.CollapsedState Property (System.Windows. ...
One of the ListViewGroupCollapsedState values that specifies how the group is displayed. The default is Default. Exceptions. InvalidEnumArgumentException. The ...
Read more >
Collapse winform listviewgroup with subtitle and footer
I like to expand/collapse a WinForm list. Without set anything to subtitle and footer properties, it works. However if I once set any...
Read more >
Add Expandable Groups in ListView .NET
Whenever the expand button is clicked, the group will expand or collapse, depending on its current state. However, in some cases this is...
Read more >
Extending C# Listview with Collapsible Groups (Part I)
Clicking on the leftmost ColumnHeader of a ListGroup should toggle the expansion/collapse of the group. · When the first column is added, the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found