Example #1
0
        protected override void OnPreviewTextInput(TextCompositionEventArgs e)
        {
            base.OnPreviewTextInput(e);

            char input = char.Parse(e.Text);

            if (input == '.')
            {
                if ((CaretIndex == Text.Length) && (mRightParagraph != null))
                {
                    mRightParagraph.Focus();
                    mRightParagraph.SelectAll();
                    e.Handled = true;
                    return;
                }
            }

            if (input < '0' || input > '9')
            {
                e.Handled = true;
                return;
            }

            if ((Text.Length >= 3) && SelectionLength == 0)
            {
                e.Handled = true;
            }
        }