-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Add Drag and Drop For Environment Variables #40105
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?
Add Drag and Drop For Environment Variables #40105
Conversation
Updated `EnvironmentVariablesMainPage.xaml` to use a `ListView` instead of an `ItemsControl`, enabling item dragging and reordering. The new `ListView` features a grid layout with a `FontIcon`, `TextBox`, and `Button`, while maintaining visibility control through data binding. Added `EditVariableValuesList_DragItemsCompleted` method in `EnvironmentVariablesMainPage.xaml.cs` to update the text box with the new order of items after drag-and-drop operations, ensuring consistency with the underlying data model.
@microsoft-github-policy-service agree |
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.
Pull Request Overview
Adds drag-and-drop reordering to the environment variable values list and synchronizes the reordered values back into the edit dialog’s text box.
- Swaps the
ItemsControl
for aListView
withCanDragItems
/CanReorderItems
enabled. - Introduces
EditVariableValuesList_DragItemsCompleted
to rebuild the semicolon-delimited value string. - Updates the item template to include a drag handle icon and repositioned action button.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
EnvironmentVariablesMainPage.xaml.cs | Added EditVariableValuesList_DragItemsCompleted handler to sync reordered items into the text box. |
EnvironmentVariablesMainPage.xaml | Replaced ItemsControl with ListView , enabled drag-and-drop, and updated the data template. |
Comments suppressed due to low confidence (1)
src/modules/EnvironmentVariables/EnvironmentVariablesUILib/EnvironmentVariablesMainPage.xaml.cs:552
- Add unit tests or UI automation tests for the drag-and-drop handler to verify that the text box is updated correctly when the ValuesList is reordered.
private void EditVariableValuesList_DragItemsCompleted(ListViewBase sender, DragItemsCompletedEventArgs args)
<ColumnDefinition Width="*" /> | ||
<ColumnDefinition Width="40" /> | ||
</Grid.ColumnDefinitions> | ||
<FontIcon |
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.
Add an AutomationProperties.Name (or appropriate accessible name) to the FontIcon used as a drag handle so that screen readers can announce its purpose.
Copilot uses AI. Check for mistakes.
{ | ||
if (EditVariableDialog.DataContext is Variable variable && variable.ValuesList != null) | ||
{ | ||
var newValues = string.Join(";", variable.ValuesList.Select(x => x.Text)); |
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.
Extract the literal separator ";" into a constant (e.g., ValueListSeparator) to avoid magic strings and improve maintainability.
var newValues = string.Join(";", variable.ValuesList.Select(x => x.Text)); | |
var newValues = string.Join(ValueListSeparator, variable.ValuesList.Select(x => x.Text)); |
Copilot uses AI. Check for mistakes.
Replaced hardcoded string separator `";"` with a constant `ValueListSeparator` in `EnvironmentVariablesMainPage.xaml.cs`. This change improves maintainability by centralizing the separator definition, making it easier to modify in the future. All instances of the separator in `string.Join` have been updated accordingly.
Summary of the Pull Request
This PR introduces drag-and-drop functionality for environment variables, allowing users to easily update the order of variables based on their preferences. Users can now rearrange variables directly in the UI by dragging and dropping, making it more intuitive and efficient to customise the order without manual editing.
PR Checklist
Detailed Description of the Pull Request / Additional comments
Updated
EnvironmentVariablesMainPage.xaml
to use aListView
instead of anItemsControl
, enabling item dragging and reordering. The newListView
features a grid layout with aFontIcon
,TextBox
, andButton
, while maintaining visibility control through data binding.Added
EditVariableValuesList_DragItemsCompleted
method inEnvironmentVariablesMainPage.xaml.cs
to update the text box with the new order of items after drag-and-drop operations, ensuring consistency with the underlying data model.Validation Steps Performed