/// <summary>
        /// Inialize necessary properties and hook necessary events on TextBox,
        /// then add it into tree.
        /// </summary>
        private void BuildTextBox(EditBox editBox)
        {
            this.mEditBox = editBox;

            this.mCanvas = new Canvas();
            this.mCanvas.Children.Add(this.mTextBox);
            this.mVisualChildren.Add(this.mCanvas);

            // Bind TextBox onto editBox control property Text
            Binding binding = new Binding("Text");

            binding.Source = editBox;
            binding.Mode   = BindingMode.TwoWay;
            binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            this.mTextBox.SetBinding(TextBox.TextProperty, binding);

            // Bind Text onto AdornedElement property Text
            binding        = new Binding("Text");
            binding.Source = this.AdornedElement;
            binding.Mode   = BindingMode.TwoWay;
            binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            this.mTextBox.SetBinding(TextBox.TextProperty, binding);

            // try to get the text box focused when layout finishes.
            this.mTextBox.LayoutUpdated += new EventHandler(this.OnTextBoxLayoutUpdated);
        }
Beispiel #2
0
        /// <summary>
        /// Inialize the EditBoxAdorner.
        ///
        ///   +---> adorningElement (TextBox)
        ///   |
        /// adornedElement (TextBlock)
        /// </summary>
        /// <param name="adornedElement"></param>
        /// <param name="adorningElement"></param>
        /// <param name="editBox"></param>
        public EditBoxAdorner(UIElement adornedElement,
                              TextBox adorningElement,
                              EditBox editBox)
            : base(adornedElement)
        {
            _TextBox = adorningElement;
            Debug.Assert(_TextBox != null, "No TextBox!");

            _VisualChildren = new VisualCollection(this);

            this.BuildTextBox(editBox);
        }
Beispiel #3
0
        /// <summary>
        /// Inialize necessary properties and hook necessary events on TextBox,
        /// then add it into tree.
        /// </summary>
        private void BuildTextBox(EditBox editBox)
        {
            _EditBox = editBox;

            _Canvas = new Canvas();
            _Canvas.Children.Add(_TextBox);
            _VisualChildren.Add(_Canvas);

            // Bind TextBox onto editBox control property Text
            Binding binding = new Binding("Text");

            binding.Source = editBox;
            binding.Mode   = BindingMode.TwoWay;
            binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            _TextBox.SetBinding(TextBox.TextProperty, binding);

            // Bind Text onto AdornedElement property Text
            binding        = new Binding("Text");
            binding.Source = this.AdornedElement;
            binding.Mode   = BindingMode.TwoWay;
            binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            _TextBox.SetBinding(TextBox.TextProperty, binding);
        }