private void selectData(TextBox sender, RoutedEventArgs e) { sender.SelectAll(); }
/// <summary> /// Visualizza una finestra di dialogo con TextBox /// </summary> public static async Task<DialogTextBoxResult> DialogTextBox(string content, string title, string box="", string ok="ok", string cancel="annulla", string sub=null, string header=null, InputScopeNameValue scopename=InputScopeNameValue.Default) { DialogTextBoxResult risposta = new DialogTextBoxResult(); risposta.result=false; risposta.output=null; StackPanel stack = new StackPanel(); if(content != null) { TextBlock contenuto = new TextBlock(); contenuto.Text = content; stack.Children.Add(contenuto); } InputScope scope = new InputScope(); scope.Names.Add(new InputScopeName(scopename)); TextBox tb = new TextBox(); tb.Text=box; tb.InputScope = scope; tb.Header = header; tb.Margin = new Thickness(0,5,0,5); stack.Children.Add(tb); if(sub!=null) { TextBlock subba = new TextBlock(); subba.Text=sub; subba.TextWrapping = TextWrapping.Wrap; stack.Children.Add(subba); } ContentDialog cd = new ContentDialog(); cd.Title = title; cd.Content = stack; cd.PrimaryButtonText = ok; cd.PrimaryButtonClick+= (s, ev) => { risposta.result=true; risposta.output=tb.Text; }; cd.SecondaryButtonText=cancel; cd.SecondaryButtonClick+= (s, ev) => { risposta.result=false; risposta.output=null; }; cd.Opened+=(s, ev) => { tb.Focus(FocusState.Keyboard); tb.SelectAll(); }; await cd.ShowAsync(); return risposta; }