Exemple #1
0
        public TextControl()
        {
            InitializeComponent();

            Loaded += (sender, e) =>
            {
                TextValue.Focus();
                TextValue.SelectAll();
            };
        }
Exemple #2
0
        private void LoadedHandler(object sender, RoutedEventArgs e)
        {
            DataContext = Settings;

            if (Settings.ValidationRule != null)
            {
                BindingOperations.GetBinding(TextValue, TextBox.TextProperty).ValidationRules.Add(Settings.ValidationRule);
                BindingOperations.GetBindingExpression(TextValue, TextBox.TextProperty).UpdateSource();
            }

            TextValue.Focus();
            TextValue.SelectAll();
        }
        /// <summary>
        /// Obtiene el valor actual
        /// </summary>
        /// <returns></returns>
        private decimal GetValueText(string operation)
        {
            decimal value = 0;

            if (!string.IsNullOrEmpty(TextValue.Text))
            {
                value = GetValueParseText(TextValue.Text);

                if (!string.IsNullOrEmpty(operation))
                {
                    typeOperation  = operation;
                    TextShow.Text  = $"{value}{operation}";
                    TextValue.Text = string.Empty;
                    TextValue.Focus();
                }
            }

            return(value);
        }