39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using CommunityToolkit.Mvvm.Messaging;
|
|
using Seyounth.Hyosung.ViewModels;
|
|
|
|
namespace Seyounth.Hyosung.Views.Windows;
|
|
|
|
public partial class PalletManagerWindow : Window
|
|
{
|
|
public PalletManagerViewModel ViewModel { get; set; }
|
|
|
|
public PalletManagerWindow(PalletManagerViewModel viewModel)
|
|
{
|
|
ViewModel = viewModel;
|
|
DataContext = this;
|
|
InitializeComponent();
|
|
WeakReferenceMessenger.Default.Register<PalletManagerViewModel.SavePalletCompletedMessage>(this, (r, m) =>
|
|
{
|
|
// 提交当前编辑并取消编辑模式
|
|
PalletDataGrid.CommitEdit();
|
|
PalletDataGrid.CancelEdit();
|
|
});
|
|
}
|
|
|
|
private void ExitButton_OnClick(object sender, RoutedEventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
|
|
private void DataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
|
|
{
|
|
// 强制提交编辑
|
|
if (e.EditAction == DataGridEditAction.Commit)
|
|
{
|
|
var binding = e.EditingElement.GetBindingExpression(TextBox.TextProperty);
|
|
binding?.UpdateSource();
|
|
}
|
|
}
|
|
} |