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

33 lines
904 B
C#
Raw Normal View History

2025-01-08 17:56:47 +08:00
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);
}
}