using Avalonia.Controls; using Avalonia.Interactivity; using LehrerApp.Desktop.ViewModels.Students; namespace LehrerApp.Desktop.Views.Students; public partial class AddStudentDialog : Window { public AddStudentDialog() => InitializeComponent(); protected override void OnOpened(EventArgs e) { base.OnOpened(e); this.FindControl("LastNameBox")?.Focus(); } private void OnSave(object? s, RoutedEventArgs e) { if (DataContext is AddStudentDialogViewModel vm && vm.SaveCommand.CanExecute(null)) { vm.SaveCommand.Execute(null); if (vm.Result is not null) Close(true); } } private void OnCancel(object? s, RoutedEventArgs e) => Close(false); }