Skip to content

Commit df30b69

Browse files
authored
Merge pull request #273 from w-ahmad/fix/cell_edit_state
fix: End editing when unloaded and commit changes
2 parents 92b8930 + 082d7ec commit df30b69

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/TableView.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public TableView()
5656
RegisterPropertyChangedCallback(ListViewBase.SelectionModeProperty, OnBaseSelectionModeChanged);
5757

5858
Loaded += OnLoaded;
59+
Unloaded += OnUnloaded;
5960
SelectionChanged += TableView_SelectionChanged;
6061
_collectionView.ItemPropertyChanged += OnItemPropertyChanged;
6162
}
@@ -319,6 +320,17 @@ private void OnLoaded(object sender, RoutedEventArgs e)
319320
EnsureAutoColumns();
320321
}
321322

323+
/// <summary>
324+
/// Handles the Unloaded event of the TableView control.
325+
/// </summary>
326+
private void OnUnloaded(object sender, RoutedEventArgs e)
327+
{
328+
if (IsEditing && CurrentCellSlot.HasValue && GetCellFromSlot(CurrentCellSlot.Value) is { } currentCell)
329+
{
330+
currentCell.EndEditing(TableViewEditAction.Commit);
331+
}
332+
}
333+
322334
/// <summary>
323335
/// Handles the PointerWheelChanged event of the ScrollContentPresenter.
324336
/// </summary>

0 commit comments

Comments
 (0)