WPF KeyUp和KeyDown

来源:互联网 发布:js输出今天的日期 编辑:程序博客网 时间:2024/05/16 16:08
xmal:
<Page x:Class="WpfBrowserApplication1.Page1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Page1">
    <Grid>
        <TextBox BorderThickness="2" BorderBrush="Red" KeyUp="TextBox_KeyUp" KeyDown="TextBox_KeyDown" >text</TextBox>
    </Grid>
</Page>

Code:
private void TextBox_KeyDown(object sender, KeyEventArgs e)
{
        MessageBox.Show(e.Key.ToString());
}

private void TextBox_KeyUp(object sender, KeyEventArgs e)
{
           MessageBox.Show(e.Key.ToString());
}
原创粉丝点击