WPF-Control/WPF控件-13-TextBox/MainWindow.xaml.cs

33 lines
904 B
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Windows;
namespace WPF控件_13_TextBox;
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void TextBox_OnLoaded(object sender, RoutedEventArgs e)
{
TextBox.Text =
"TextWrapping=\"Wrap\" 是否换行 \n" +
" AcceptsReturn=\"True\" 收否回车键换行 \n" +
" AutoWordSelection=\"True\" 自动选择文本单词 \n " +
"IsUndoEnabled=\"False\" 是否开启Undo";
}
private void UndoButton_OnClick(object sender, RoutedEventArgs e)
{
var undo = TextBox.Undo();
Console.WriteLine($"undo{undo}");
var textBoxCanUndo = TextBox.CanUndo;
var canUndo = $"TextBox can undo: {textBoxCanUndo}";
Console.WriteLine(canUndo);
}
}