Skip to content

Commit

Permalink
remove CellEditEndingCommand, CommitEditCommand. add Committed event
Browse files Browse the repository at this point in the history
  • Loading branch information
soomin-kevin-sung committed Oct 24, 2023
1 parent b0fcae9 commit ca1bb53
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 25 deletions.
33 changes: 8 additions & 25 deletions src/KevinComponent/FlexGrid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,12 @@ public FlexGrid()
"UnSelectAllByEscapeKey",
typeof(bool),
typeof(FlexGrid), new FrameworkPropertyMetadata(false));
public static readonly DependencyProperty CellEditEndingCommandProperty =
DependencyProperty.Register(
"CellEditEndingCommand",
typeof(ICommand),
typeof(FlexGrid),
new FrameworkPropertyMetadata(null));
public static readonly DependencyProperty CommittedCommandProperty =
DependencyProperty.Register(
"CommittedCommand",
typeof(ICommand),
typeof(FlexGrid),
new FrameworkPropertyMetadata(null));

#endregion

#region Public Events

public event EventHandler<FlexGridCommittedArgs> Committed;

#endregion

Expand Down Expand Up @@ -76,18 +70,6 @@ public bool IsEditing
}
}

public ICommand CellEditEndingCommand
{
get => (ICommand)GetValue(CellEditEndingCommandProperty);
set => SetValue(CellEditEndingCommandProperty, value);
}

public ICommand CommittedCommand
{
get => (ICommand)GetValue(CommittedCommandProperty);
set => SetValue(CommittedCommandProperty, value);
}

#endregion

#region Internal Properties
Expand Down Expand Up @@ -249,7 +231,8 @@ public void PerformSort(DataGridColumn sortColumn)
protected override void OnExecutedCommitEdit(ExecutedRoutedEventArgs e)
{
base.OnExecutedCommitEdit(e);
CommittedCommand?.Execute(null);
if (CurrentCell != null)

Check warning on line 234 in src/KevinComponent/FlexGrid.cs

View workflow job for this annotation

GitHub Actions / build

The result of the expression is always 'true' since a value of type 'DataGridCellInfo' is never equal to 'null' of type 'DataGridCellInfo?'

Check warning on line 234 in src/KevinComponent/FlexGrid.cs

View workflow job for this annotation

GitHub Actions / build

The result of the expression is always 'true' since a value of type 'DataGridCellInfo' is never equal to 'null' of type 'DataGridCellInfo?'

Check warning on line 234 in src/KevinComponent/FlexGrid.cs

View workflow job for this annotation

GitHub Actions / build

The result of the expression is always 'true' since a value of type 'DataGridCellInfo' is never equal to 'null' of type 'DataGridCellInfo?'

Check warning on line 234 in src/KevinComponent/FlexGrid.cs

View workflow job for this annotation

GitHub Actions / build

The result of the expression is always 'true' since a value of type 'DataGridCellInfo' is never equal to 'null' of type 'DataGridCellInfo?'
Committed?.Invoke(this, new FlexGridCommittedArgs(CurrentCell));
}

protected override void OnPreviewKeyDown(KeyEventArgs e)
Expand Down
19 changes: 19 additions & 0 deletions src/KevinComponent/FlexGridCommittedArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;

namespace KevinComponent
{
public class FlexGridCommittedArgs : EventArgs
{
public FlexGridCommittedArgs(DataGridCellInfo cellInfo)
{
CellInfo = cellInfo;
}

public DataGridCellInfo CellInfo { get; }
}
}

0 comments on commit ca1bb53

Please sign in to comment.