@using MudBlazor Create New File Cancel Create @code { [CascadingParameter] IMudDialogInstance Dialog { get; set; } = null!; private string FileName { get; set; } = string.Empty; private void Cancel() => Dialog.Cancel(); private void Submit() { if (string.IsNullOrWhiteSpace(FileName)) { return; } // Ensure .cs extension var name = FileName.Trim(); if (!name.EndsWith(".cs", StringComparison.OrdinalIgnoreCase)) { name += ".cs"; } Dialog.Close(DialogResult.Ok(name)); } private void HandleKeyDown(KeyboardEventArgs e) { if (e.Key == "Enter") { Submit(); } else if (e.Key == "Escape") { Cancel(); } } }