지울 필요가 없거나 충분히 on off 를 조절 하여 사용할 수 있는 환경이라면 구지 XAML 이나 += 로 추가 하지 않아도 아래와 같은 방법으로 override 하여 사용하면 깔끔하다.
protected override void OnMouseDown(MouseButtonEventArgs e) { base.OnMouseDown(e); this.Focus(); Console.WriteLine("req focus"); } protected override void OnMouseEnter(MouseEventArgs e) { ((SolidColorBrush)(_circle.Fill)).Color = OverColor; } protected override void OnMouseLeave(MouseEventArgs e) { ((SolidColorBrush)(_circle.Fill)).Color = NormalColor; } protected override void OnPreviewKeyDown(KeyEventArgs e) { base.OnPreviewKeyDown(e); Keyboard_Press_ArrowType key_type = Keyboard_Press_ArrowType.NONE; if (e.Key == Key.OemComma) { key_type = Keyboard_Press_ArrowType.LEFT; } else if (e.Key == Key.OemPeriod) { key_type = Keyboard_Press_ArrowType.RIGHT; } if (key_type != Keyboard_Press_ArrowType.NONE) { if (KeyboardPressEvent != null) { KeyboardPressEvent(this, new SNCircleThumbEvent() { keyPressType = key_type }); } } } |
'C#' 카테고리의 다른 글
[WPF] 이미지 블러링을 원천적으로 해결하 (2) | 2015.01.07 |
---|---|
[WPF] 키보드 포커스 가져오기 / 삭제하기 (0) | 2015.01.06 |
[WPF] UserControl 에서 간단 마우스,키보드 이벤트 수신법 (0) | 2015.01.06 |
[WPF] 멀티쓰레드 상황에서 WPF Control 캡처 하기 (4) | 2014.11.05 |
[메모] 이중 반복문이 느리다. (1) | 2014.07.30 |
웹캠 포커스 강제 설정방법 (0) | 2014.07.29 |