Esempio n. 1
0
        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);
            PositionTextBox.Focus();

            Dispatcher.BeginInvoke((Action)PositionTextBox.SelectAll, DispatcherPriority.Loaded);
        }
        private void PositionTextBox_Validating(object sender, System.ComponentModel.CancelEventArgs e)
        {
            string namePattern = @"[а-я]";

            var positionIsMatch = Regex.IsMatch(PositionTextBox.Text, namePattern);

            if (String.IsNullOrEmpty(PositionTextBox.Text))
            {
                e.Cancel = true;
                PositionTextBox.Focus();
                ErrorProvider.SetError(PositionTextBox, "Укажите должность");
            }
            else if (positionIsMatch == false)
            {
                e.Cancel = true;
                PositionTextBox.Focus();
                ErrorProvider.SetError(PositionTextBox, "Неверный формат");
            }
            else
            {
                e.Cancel = false;
                ErrorProvider.SetError(PositionTextBox, null);
            }
        }