-
Notifications
You must be signed in to change notification settings - Fork 982
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Collapsible/Collapsed for ListViewGroup #3155
Conversation
src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroup.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ListViewGroupTests.cs
Show resolved
Hide resolved
src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ListViewGroupTests.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ListViewGroupTests.cs
Show resolved
Hide resolved
src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ListViewGroupTests.cs
Outdated
Show resolved
Hide resolved
get => _collapsible; | ||
set | ||
{ | ||
if (_collapsible == value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider the following code:
lvg.Collapsible = true;
lvg.Collapsed = true;
lvg.Collapsible = false;
We will get into an invalid state. Should we force collapsed to false when setting Collapsible to false?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the catch! I think we should force Collapsed to be false whenever Collapsible is false. This way whenever users set Collapsible to true, Collapsed will initially be false.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The alternative would be to ignore lvg.Collapsible = false;
if Collapsed is already true. Do we have similarly connected properties in other controls? What are they doing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked into files like GridEntry.cs
which has Expandable/Expanded and it seems that Expandable is read-only and cannot be changed externally. Internally, there doesn't seem to be a place where Expandable is altered from its initial value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly nits
src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroupCollection.cs
Outdated
Show resolved
Hide resolved
@msftbot merge if @Tanya-Solyanik approves |
Hello @RussKie! Because you've given me some instructions on how to help merge this pull request, I'll be modifying my merge approach. Here's how I understand your requirements for merging this pull request:
If this doesn't seem right to you, you can tell me to cancel these instructions and use the auto-merge policy that has been configured for this repository. Try telling me "forget everything I just told you". |
src/System.Windows.Forms/tests/IntegrationTests/WinformsControlsTest/ListViewTest.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Waiting for conclusion of ISupportInitialized discussion, otherwise looks good.
src/System.Windows.Forms/tests/IntegrationTests/WinformsControlsTest/ListViewTest.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ListViewGroupTests.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ListViewGroupTests.cs
Show resolved
Hide resolved
src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ListViewGroupTests.cs
Outdated
Show resolved
Hide resolved
I noticed this also. When I was working on collapse through keyboard-only and sending group messages, windows gave default group an index of 0. It makes me think that we should also keep track of a default group as index 0 in the |
Because the user didn't add it. Its a user-maintained collection and you want to keep up the illusion of items existing without group. A group repeatedly appearing/disappearing in slot zero would be very disturbing to user code. some more reasons:
I don't think you can change that behavior because it will be a breaking change for anyone looping over the groups for processing items. |
Aye, it places us in a weird place - a user can alter own groups but has no control over the default group. This would lead to strange UX. In https://github.com/gitextensions/gitextensions we've bolted on a group collapsibility to winforms/src/System.Windows.Forms/src/System/Windows/Forms/ListView.cs Lines 760 to 770 in 7a54b53
Further it the
|
src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroupCollapsedState.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroupCollapsedState.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroupCollapsedState.cs
Outdated
Show resolved
Hide resolved
You can expose it as a property, no need to make it part of the enumerable collection. The property can be either on the control or on the collection. |
2e07ecc
to
922bb32
Compare
922bb32
to
9f94665
Compare
Fixes #3067 ListViewGroup originally was not collapsible and thus items in the group could not be temporarily hidden. These changes add a new property to ListViewGroup which controls its appearance e.g. whether the group is collapsible and if the group is in its collapsed state or expanded state. These changes also raise an event for when the CollapsedState of a group is changed.
9f94665
to
0fd955f
Compare
Well done! Thank you |
Accessibility for ListViewGroup expanded/collapsed state and action is covered in #3224. |
@lonitra Just out of curiosity, I was wondering if there is some keyboard combination to Expand/Collapse the ListViewGroup. For now, only can using mouse to click the Icon of Expanded/Collapsed or double-clicking on the whole Group. |
@Vino-Wang As of right now there's not. Ideally the groups would collapse/expand with left and right arrow key. I have made a work item for it here #3269 @M-Lipin Does #3224 cover collapse/expand through keyboard only? If not I can go ahead and take care of this 😊 |
Looping in @Ryuugamine instead of Mikhail. |
Fixes #3067
Proposed changes
ListViewGroup
Customer Impact
Screenshots
Before
After
Test methodology
TODOs
Notes
Microsoft Reviewers: Open in CodeFlow