Beispiel #1
0
 private void UnSetupDataContext(NumberBoxModel model)
 {
     model.FocusRequest      -= Model_FocusRequest;
     model.SelectRequest     -= Model_SelectRequest;
     model.CaretIndexChanged -= Model_CaretIndexChanged;
     model.PreviewTextInput  -= Model_PreviewTextInput;
 }
        /// <summary>
        /// Tab键按下时的响应;
        /// </summary>
        private bool OnTabKeyDown()
        {
            var currentWritableNumberBox = GetCurrentWritableNumberBox();

            if (currentWritableNumberBox?.Number == null)
            {
                return(true);
            }

            var            index         = _numberBoxes.IndexOf(currentWritableNumberBox);
            NumberBoxModel nextNumberBox = null;

            if (index == _numberBoxes.Count - 1)
            {
                nextNumberBox = _numberBoxes[0];
            }
            else
            {
                nextNumberBox = _numberBoxes[index + 1];
            }

            currentWritableNumberBox.IsReadOnly = true;

            if (IsInputing)
            {
                IsInputing = false;
                currentWritableNumberBox.TabConfirm();
            }

            nextNumberBox.IsReadOnly = false;

            nextNumberBox.SelectAll();
            nextNumberBox.Focus();

            return(true);
        }