Beispiel #1
0
 /// <summary>
 /// Gives focus to the first control in the tree.
 /// </summary>
 /// <param name="sender">The label area element.</param>
 /// <param name="e">Mouse Button Event Args.</param>
 private void LabelAreaElement_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     UIElement content = this.Content as UIElement;
     if (content != null)
     {
         Control control = LabeledContentControl.GetFirstControl(content);
         if (control != null)
         {
             FocusHelper.FocusControl(control);
         }
     }
 }
Beispiel #2
0
        /// <summary>
        /// Collapses the list, if behaviour is not overriden.
        /// </summary>
        /// <param name="sender">The cascading list box item.</param>
        /// <param name="e">Selected Event Args.</param>
        private void CascadingListBoxItem_Selected(object sender, SelectedEventArgs e)
        {
            if (this.CollapseOnSelection && !e.Handled)
            {
                this.IsExpanded = false;
            }

            FocusHelper.FocusControl(this);

            if (e.SelectedItem != this.OtherItem)
            {
                this.RaiseItemSelected();
            }
        }
Beispiel #3
0
        /// <summary>
        /// Moves focus to the correct control.
        /// </summary>
        /// <param name="sender">The cascading list box.</param>
        /// <param name="e">Routed Event Args.</param>
        private void CascadingListBox_GotFocus(object sender, RoutedEventArgs e)
        {
            CompositionTarget.Rendering -= new EventHandler(this.CompositionTargetRendering_LostFocus);
            this.isFocused = true;
#if !SILVERLIGHT
            if (e.OriginalSource == this || e.OriginalSource == this.selectedItemButton || e.OriginalSource is CascadingListBoxItem)
            {
                this.IsTabStop = false;
            }
#endif
#if !SILVERLIGHT
            if (this.lastFocusedElement != e.OriginalSource && this.SelectedItem == null || (!this.IsExpanded && e.OriginalSource is CascadingListBoxItem))
            {
                this.lastFocusedElement = e.OriginalSource;
            }

            if (!this.IsExpanded && (e.OriginalSource is CascadingListBoxItem) && this.lastFocusedElement == e.OriginalSource && this.selectedItemButton != null)
            {
                FocusHelper.FocusControl(this.selectedItemButton);
            }
            else
            {
                this.lastFocusedElement = e.OriginalSource;
            }
#endif

            if (this.focusSelectedItem && this.IsExpanded && this.ConfirmedSelectedItem != null && this.containersByItem.ContainsKey(this.ConfirmedSelectedItem))
            {
                this.containersByItem[this.ConfirmedSelectedItem].Focus();
                this.focusSelectedItem = false;
            }
            else if (this.IsExpanded && this.SelectedItem != null && this.containersByItem.ContainsKey(this.SelectedItem))
            {
                this.containersByItem[this.SelectedItem].Focus();
            }
            else if (this.IsExpanded && (this.SelectedItem == null || this.SelectedItem == this.OtherItem) && this.Items.Count > 0 && (!this.Items.Contains(this.OtherItem) || this.SelectedIndex != this.Items.IndexOf(this.OtherItem)))
            {
                this.SelectedItem = this.Items[0];

                if (this.containersByItem.ContainsKey(this.Items[0]))
                {
                    this.containersByItem[this.Items[0]].Focus();
                }
            }
            else if (!this.IsExpanded && this.selectedItemButton != null && this.ConfirmedSelectedItem != null && e.OriginalSource != this.selectedItemButton)
            {
                this.selectedItemButton.Focus();
            }
        }
Beispiel #4
0
        /// <summary>
        /// Updates the UI.
        /// </summary>
        /// <param name="isFieldShowing">Whether the field is showing.</param>
        private void UpdateIsFieldShowing(bool isFieldShowing)
        {
            if (this.contentPresenter != null && this.showFieldButton != null)
            {
                if (isFieldShowing && this.Content != null)
                {
                    this.contentPresenter.Visibility = Visibility.Visible;
                    this.showFieldButton.Visibility  = Visibility.Collapsed;

                    if (this.isFocused)
                    {
                        Control       control       = this.Control != null ? this.Control : GetFirstControl(this.Content as UIElement);
                        SplitComboBox splitComboBox = control as SplitComboBox;
                        if (splitComboBox != null)
                        {
                            splitComboBox.OpenDropDownOnGotFocus = true;
                        }

                        FocusHelper.FocusControl(control);
                    }

                    if (this.Expanded != null)
                    {
                        this.Expanded(this, EventArgs.Empty);
                    }
                }
                else
                {
                    this.showFieldButton.Visibility  = Visibility.Visible;
                    this.contentPresenter.Visibility = Visibility.Collapsed;

                    if (this.isFocused)
                    {
                        FocusHelper.FocusControl(this.showFieldButton);
                    }

                    if (this.Collapsed != null)
                    {
                        this.Collapsed(this, EventArgs.Empty);
                    }
                }
            }
        }
Beispiel #5
0
 /// <summary>
 /// Sets the text box text, and selects all.
 /// </summary>
 /// <param name="sender">The composition target.</param>
 /// <param name="e">Event Args.</param>
 private void CompositionTargetRendering_SetTextBoxText(object sender, EventArgs e)
 {
     CompositionTarget.Rendering -= new EventHandler(this.CompositionTargetRendering_SetTextBoxText);
     this.textBox.Text            = this.SelectedDateText;
     FocusHelper.FocusControl(this.textBox);
 }