private static void setTextIfUnfocused(ExtendedTextBox textBox, string text)
 {
     if (textBox.IsKeyboardFocused)
     {
         return;
     }
     textBox.SetText(text);
 }
        private void initialise()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
            {
                return;
            }

            if (this.textbox != null)
            {
                throw new Exception("Auto completion popup cannot be initialised more than once.");
            }

            this.textbox = this.TextBox;

            if (this.textbox == null)
            {
                throw new Exception("Auto completion popup must have a valid text box.");
            }

            this.textbox.PreviewKeyDown    += this.textboxOnPreviewKeyDown;
            this.textbox.TextChanged       += this.textboxOnTextChanged;
            this.textbox.LostKeyboardFocus += (sender, args) =>
            {
                if (this.textbox.Focusable && this.textbox.IsEnabled)
                {
                    var element = Keyboard.FocusedElement as FrameworkElement;
                    while (true)
                    {
                        if (element == null)
                        {
                            break;
                        }

                        if (element == this)
                        {
                            this.textbox.Focus();
                            return;
                        }

                        element = element.Parent as FrameworkElement;
                    }
                }

                this.close();
            };
        }
        private void initialise()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;

            if (this.textbox != null)
                throw new Exception("Auto completion popup cannot be initialised more than once.");

            this.textbox = this.TextBox;

            if (this.textbox == null)
                throw new Exception("Auto completion popup must have a valid text box.");

            this.textbox.PreviewKeyDown += this.textboxOnPreviewKeyDown;
            this.textbox.TextChanged += this.textboxOnTextChanged;
            this.textbox.LostKeyboardFocus += (sender, args) =>
            {
                if (this.textbox.Focusable && this.textbox.IsEnabled)
                {
                    var element = Keyboard.FocusedElement as FrameworkElement;
                    while (true)
                    {
                        if (element == null)
                            break;

                        if (element == this)
                        {
                            this.textbox.Focus();
                            return;
                        }

                        element = element.Parent as FrameworkElement;
                    }
                }

                this.close();
            };
        }
Example #4
0
 private void setText(ExtendedTextBox textBox, string text, bool evenIfFocused)
 {
     if (evenIfFocused || !textBox.IsKeyboardFocused)
     {
         textBox.SetText(text);
     }
 }
Example #5
0
 private static void setTime(ExtendedTextBox textBox, string time, bool evenIfFocused)
 {
     if (evenIfFocused || !textBox.IsKeyboardFocused)
     {
         textBox.SetText(time);
         textBox.Tag = time;
     }
 }
 private static void setTextIfUnfocused(ExtendedTextBox textBox, string text)
 {
     if (textBox.IsFocused)
         return;
     textBox.SetText(text);
 }
        private void initialise()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;

            if (this.textbox != null)
                throw new Exception("Auto completion popup cannot be initialised more than once.");

            this.textbox = this.TextBox;

            if (this.textbox == null)
                throw new Exception("Auto completion popup must have a valid text box.");

            this.textbox.PreviewKeyDown += this.textboxOnPreviewKeyDown;
            this.textbox.TextChanged += this.textboxOnTextChanged;
            this.textbox.LostKeyboardFocus += (sender, args) => this.close();
        }
Example #8
0
 private static void setTime(ExtendedTextBox textBox, string time)
 {
     textBox.SetText(time);
     textBox.Tag = time;
 }