36 lines
1.0 KiB
C#
36 lines
1.0 KiB
C#
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using MaterialDesignThemes.Wpf;
|
|
using Seyounth.Hyosung.Data.Entities;
|
|
using Seyounth.Hyosung.Data.Models;
|
|
using Seyounth.Hyosung.ViewModels;
|
|
using Seyounth.Hyosung.Views.Controls;
|
|
|
|
namespace Seyounth.Hyosung.Views.Pages;
|
|
|
|
public partial class VarietyPage : Page
|
|
{
|
|
public VarietyViewModel ViewModel { get; set; }
|
|
|
|
|
|
public VarietyPage(VarietyViewModel viewModel)
|
|
{
|
|
ViewModel = viewModel;
|
|
DataContext = this;
|
|
InitializeComponent();
|
|
}
|
|
|
|
|
|
private async void ButtonBase_OnClick(object sender, RoutedEventArgs e)
|
|
{
|
|
var blankVariety = new VarietyEntity()
|
|
;
|
|
// 将空白对象添加到数据源中
|
|
ViewModel.Varieties.Add(blankVariety);
|
|
// 滚动到新添加的行并使其进入编辑状态
|
|
VarietyDataGrid.ScrollIntoView(blankVariety);
|
|
var index = ViewModel.Varieties.IndexOf(blankVariety);
|
|
VarietyDataGrid.SelectedIndex = index;
|
|
VarietyDataGrid.BeginEdit();
|
|
}
|
|
} |