반응형

XMAL

<StackPanel>
  <TextBlock Width="300" Height="20">
    Type some text into the TextBox and press the Enter key.
  </TextBlock>
  <TextBox Width="300" Height="30" Name="textBox1"
           KeyDown="OnKeyDownHandler"/>
  <TextBlock Width="300" Height="100" Name="textBlock1"/>
</StackPanel>


C#

private void OnKeyDownHandler(object sender, KeyEventArgs e)
{
    if (e.Key == Key.Return)
    {
        textBlock1.Text = "You Entered: " + textBox1.Text;
    }
}

XAML에서 KeyDown 이벤트를 설정 해 주고 코드로 와서 key.값을 입력 해준다

반응형

'프로그래밍 > WPF' 카테고리의 다른 글

[Design Pattern] WPF Singleton (싱글톤 패턴)  (5) 2014.02.14
[Blend4] WPF SketchFlow  (0) 2013.10.04
[WPF] Binding Property  (0) 2013.08.02
[WPF] Binding(바인딩)  (0) 2013.08.01
[WPF] Dynamic Resource & Static Resource  (0) 2013.05.21