WPF KeyUp和KeyDown

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());
}

你可能感兴趣的:(object,Class,WPF,textbox)