Exemple #1
0
        /// <summary>
        /// 为一个运行时的 Command 生成 TextBox 控件。
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        protected static TextBox CreateTextBox(ClientCommand command)
        {
            var textBox = new TipTextBox()
            {
                Width             = 150,
                VerticalAlignment = VerticalAlignment.Center,
                Margin            = new Thickness(2),
                EmptyValue        = command.Label,
                ToolTip           = command.Meta.ToolTip.Translate()
            };

            //当TextBox的值改变时,通知命令进行新的输入值
            textBox.TextChanged += (o, e) =>
            {
                var txt = textBox.Text;
                if (txt == textBox.EmptyValue)
                {
                    txt = string.Empty;
                }
                SetTextBoxParameter(command, txt);
            };

            //支持UI Test
            AutomationProperties.SetName(textBox, command.Label);

            return(textBox);
        }
Exemple #2
0
        /// <summary>
        /// 为一个运行时的 Command 生成 TextBox 控件。
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        protected static TextBox CreateTextBox(ClientCommand command)
        {
            var textBox = new TipTextBox()
            {
                Width = 150,
                VerticalAlignment = VerticalAlignment.Center,
                Margin = new Thickness(2),
                EmptyValue = command.Label,
                ToolTip = command.Meta.ToolTip.Translate()
            };

            //当TextBox的值改变时,通知命令进行新的输入值
            textBox.TextChanged += (o, e) =>
            {
                var txt = textBox.Text;
                if (txt == textBox.EmptyValue) { txt = string.Empty; }
                SetTextBoxParameter(command, txt);
            };

            //支持UI Test
            AutomationProperties.SetName(textBox, command.Label);

            return textBox;
        }