using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;

namespace EventSample
{
    public class NumericTextBox: TextBox
    {
        protected override void OnKeyDown(System.Windows.Input.KeyEventArgs e)
        {

            if((e.Key== System.Windows.Input.Key.Back)||
                (e.Key >= System.Windows.Input.Key.D1 &&
                 e.Key <= System.Windows.Input.Key.D9))
            {
                base.OnKeyDown(e);
                return;
            }
            e.Handled = true;  //取消事件
            
        }

    }
}
