110,566
社区成员
发帖
与我相关
我的任务
分享
<Window x:Class="WPF1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WPF1"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<TextBox TextChanged="TextBox_TextChanged"/>
</Grid>
</Window>
private void TextBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
{
TextBox tb = sender as TextBox;
tb.Text = tb.Text.Replace(" ","");
}