-
-
Notifications
You must be signed in to change notification settings - Fork 50
Add ListView-like hotkeys support to TableView #251
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -256,8 +256,11 @@ | |||||||||
| public static readonly DependencyProperty CanReorderColumnsProperty = DependencyProperty.Register(nameof(CanReorderColumns), typeof(bool), typeof(TableView), new PropertyMetadata(true)); | ||||||||||
|
|
||||||||||
| /// <summary> | ||||||||||
| /// Identifies the UseListViewHotkeys dependency property. | ||||||||||
| /// </summary> | ||||||||||
| public static readonly DependencyProperty UseListViewHotkeysProperty = DependencyProperty.Register(nameof(UseListViewHotkeys), typeof(bool), typeof(TableView), new PropertyMetadata(false)); | ||||||||||
| /// Identifies the <see cref="ConditionalCellStyles"/> dependency property. | ||||||||||
| /// </summary> | ||||||||||
|
Check warning on line 263 in src/TableView.Properties.cs
|
||||||||||
| public static readonly DependencyProperty ConditionalCellStylesProperty = DependencyProperty.Register(nameof(ConditionalCellStyles), typeof(IList<TableViewConditionalCellStyle>), typeof(TableView), new PropertyMetadata(default)); | ||||||||||
|
|
||||||||||
| /// <summary> | ||||||||||
|
|
@@ -768,6 +771,15 @@ | |||||||||
| set => SetValue(CanReorderColumnsProperty, value); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /// <summary> | ||||||||||
| /// Gets or sets whether the TableView should use ListView like hotkeys for navigation and selection. | ||||||||||
|
||||||||||
| /// Gets or sets whether the TableView should use ListView like hotkeys for navigation and selection. | |
| /// Gets or sets a value indicating whether the <see cref="TableView"/> uses ListView-style keyboard | |
| /// navigation in multiple selection mode, where Up/Down move the focused row, Enter toggles selection | |
| /// of the focused row, and Shift+Up/Down extends the selection without deselecting other items. |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |||||||||||||||||||
| using Microsoft.UI.Xaml.Controls.Primitives; | ||||||||||||||||||||
| using Microsoft.UI.Xaml.Data; | ||||||||||||||||||||
| using Microsoft.UI.Xaml.Input; | ||||||||||||||||||||
| using Microsoft.UI.Xaml.Media; | ||||||||||||||||||||
| using System; | ||||||||||||||||||||
| using System.Collections; | ||||||||||||||||||||
| using System.Collections.Generic; | ||||||||||||||||||||
|
|
@@ -129,6 +130,13 @@ protected override DependencyObject GetContainerForItemOverride() | |||||||||||||||||||
| _rows.Add(row); | ||||||||||||||||||||
| return row; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| private bool IsRowKeyboardContext => | ||||||||||||||||||||
| (UseListViewHotkeys == true) && //Not sure if I'm solving a bug or adding a feature, so I've made it apply only when the UseListViewHotkeys is set to true just in case. | ||||||||||||||||||||
|
||||||||||||||||||||
| (UseListViewHotkeys == true) && //Not sure if I'm solving a bug or adding a feature, so I've made it apply only when the UseListViewHotkeys is set to true just in case. | |
| UseListViewHotkeys && //Not sure if I'm solving a bug or adding a feature, so I've made it apply only when the UseListViewHotkeys is set to true just in case. |
Copilot
AI
Dec 18, 2025
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 IsRowKeyboardContext property is missing XML documentation. According to the project's coding guidelines (CS1591 enforced as error), all public types and members must have XML documentation comments. Private members should also be documented when their purpose is not immediately obvious. Add a summary explaining that this property determines when ListView-style keyboard navigation should be applied based on the UseListViewHotkeys setting and current selection context.
Copilot
AI
Dec 18, 2025
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.
There are excessive trailing spaces after the closing brace. Remove the unnecessary whitespace to maintain clean code formatting.
Copilot
AI
Dec 18, 2025
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 ToggleCurrentRowSelection method is missing XML documentation. Add a summary explaining that this method toggles the selection state of the currently focused or selected row when in Multiple selection mode.
| /// <summary> | |
| /// Toggles the selection state of the currently focused or selected row when in Multiple selection mode. | |
| /// </summary> |
Copilot
AI
Dec 18, 2025
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.
There are excessive blank lines here (two consecutive empty lines). According to typical code style practices and for consistency with the rest of the codebase, there should be only one blank line between method declarations.
Copilot
AI
Dec 18, 2025
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.
There is an unnecessary blank line at the start of this method. Remove it to maintain consistency with the coding style used elsewhere in the codebase.
Copilot
AI
Dec 18, 2025
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.
There is an unnecessary blank line here. Remove it to maintain consistent spacing within the method.
Copilot
AI
Dec 18, 2025
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.
This condition check is redundant. The index value is already validated in lines 208-218 where it's either set from GetFocusedRowIndex() (which returns -1 if invalid) or from CurrentRowIndex/SelectedIndex (which are validated against the same bounds). If index passes the earlier checks, it cannot be less than 0 or greater than or equal to Items.Count at this point.
| if (index < 0 || index >= Items.Count) { return; } |
Copilot
AI
Dec 18, 2025
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.
There is an unnecessary blank line at the end of this method. Remove it to maintain consistency with the coding style used elsewhere in the codebase.
Copilot
AI
Dec 18, 2025
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 GetFocusedRowIndex method is missing XML documentation. Add a summary explaining that this method retrieves the index of the currently focused row, or returns -1 if no row has focus or if XamlRoot is not available.
| /// <summary> | |
| /// Retrieves the index of the currently focused row, or returns -1 if no row has focus or if XamlRoot is not available. | |
| /// </summary> | |
| /// <returns> | |
| /// The index of the currently focused row, or -1 if no row has focus or if XamlRoot is not available. | |
| /// </returns> |
Copilot
AI
Dec 18, 2025
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 GetRowFromElement method is missing XML documentation. Add a summary and param documentation explaining that this method traverses the visual tree upward from the given element to find the containing TableViewRow, returning null if no row is found.
| /// <summary> | |
| /// Traverses the visual tree upward from the specified element to find the containing <see cref="TableViewRow"/>. | |
| /// </summary> | |
| /// <param name="element">The starting element from which to search up the visual tree for a containing <see cref="TableViewRow"/>.</param> | |
| /// <returns> | |
| /// The <see cref="TableViewRow"/> that contains the provided element, or <c>null</c> if no containing row is found. | |
| /// </returns> |
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 XML documentation comment for this dependency property declaration is incomplete. It's missing the closing summary tag on line 262, which causes the next documentation comment to be malformed. The summary should be properly closed before the next field declaration.