Skip to content

Commit 3b9a06a

Browse files
committed
fixed selection check mark states
1 parent bba7319 commit 3b9a06a

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

src/TableView.Properties.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public partial class TableView
209209
/// <summary>
210210
/// Gets or sets a value indicating whether the TableView is in editing mode.
211211
/// </summary>
212-
internal bool IsEditing { get; set; }
212+
internal bool IsEditing { get; private set; }
213213

214214
/// <summary>
215215
/// Gets the width of the selection indicator.

src/TableView.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ private void HandleNavigations(KeyRoutedEventArgs e, bool shiftKey, bool ctrlKey
154154
}
155155
else if (e.Key is VirtualKey.Escape && currentCell is not null && IsEditing)
156156
{
157+
SetIsEditing(false);
157158
currentCell?.SetElement();
158-
IsEditing = false;
159159
e.Handled = true;
160160
}
161161
else if (e.Key is VirtualKey.Space && currentCell is not null && CurrentCellSlot.HasValue && !IsEditing)
@@ -1392,7 +1392,7 @@ internal void UpdateCornerButtonState()
13921392
{
13931393
_headerRow?.SetCornerButtonState();
13941394

1395-
DispatcherQueue.TryEnqueue(Microsoft.UI.Dispatching.DispatcherQueuePriority.Low,() =>
1395+
DispatcherQueue.TryEnqueue(Microsoft.UI.Dispatching.DispatcherQueuePriority.Low, () =>
13961396
{
13971397
if (SelectionMode is ListViewSelectionMode.Multiple && SelectionUnit is not TableViewSelectionUnit.Cell)
13981398
{
@@ -1404,6 +1404,17 @@ internal void UpdateCornerButtonState()
14041404
});
14051405
}
14061406

1407+
internal void SetIsEditing(bool value)
1408+
{
1409+
if (IsEditing == value)
1410+
{
1411+
return;
1412+
}
1413+
1414+
IsEditing = value;
1415+
UpdateCornerButtonState();
1416+
}
1417+
14071418
public virtual void OnSorting(TableViewSortingEventArgs eventArgs)
14081419
{
14091420
Sorting?.Invoke(this, eventArgs);

src/TableViewCell.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,10 +284,11 @@ private void MakeSelection()
284284
TableView.DeselectCell(Slot);
285285
}
286286

287-
TableView.IsEditing = false;
288-
TableView.UpdateCornerButtonState();
289287
TableView.MakeSelection(Slot, shiftKey, ctrlKey);
290288
}
289+
290+
TableView.SetIsEditing(false);
291+
TableView.UpdateCornerButtonState();
291292
}
292293

293294
/// <summary>
@@ -339,7 +340,7 @@ private void SetEditingElement()
339340

340341
if (TableView is not null)
341342
{
342-
TableView.IsEditing = true;
343+
TableView.SetIsEditing(true);
343344
TableView.UpdateCornerButtonState();
344345
}
345346
}

src/TableViewRow.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public partial class TableViewRow : ListViewItem
1919
{
2020
private const string Selection_Indictor = nameof(Selection_Indictor);
2121
private const string Selection_Background = nameof(Selection_Background);
22+
private const string Check_Mark = "\uE73E";
2223
private Thickness _focusVisualMargin = new(1);
2324
private Thickness _selectionBackgroundMargin = new(4, 2, 4, 2);
2425

@@ -525,7 +526,7 @@ internal void EnsureAlternateColors()
525526

526527
internal void UpdateSelectCheckMarkOpacity()
527528
{
528-
var fontIcon = this.FindDescendant<FontIcon>(x => x.Parent is Border);
529+
var fontIcon = this.FindDescendant<FontIcon>(x => x.Glyph == Check_Mark);
529530

530531
if (fontIcon?.Parent is Border border)
531532
{

0 commit comments

Comments
 (0)