Example #1
0
        /// <inheritdoc/>
        protected override void OnGotFocus(GotFocusEventArgs e)
        {
            base.OnGotFocus(e);

            if (e.NavigationMethod == NavigationMethod.Directional)
            {
                e.Handled = UpdateSelectionFromEventSource(e.Source);
            }
        }
Example #2
0
 /// <inheritdoc/>
 protected override void OnGotFocus(GotFocusEventArgs e)
 {
     if (e.NavigationMethod == NavigationMethod.Directional)
     {
         e.Handled = UpdateSelectionFromEventSource(
             e.Source,
             true,
             (e.InputModifiers & InputModifiers.Shift) != 0);
     }
 }
Example #3
0
        protected override void OnGotFocus(GotFocusEventArgs e)
        {
            var control = (IControl)e.Source;
            var item = ItemContainerGenerator.ItemFromContainer(control);

            if (item != null)
            {
                SelectedItem = item;
                e.Handled = true;
            }
        }
Example #4
0
 /// <summary>
 /// Called before the <see cref="GotFocus"/> event occurs.
 /// </summary>
 /// <param name="e">The event args.</param>
 protected virtual void OnGotFocus(GotFocusEventArgs e)
 {
     IsFocused = e.Source == this;
 }
Example #5
0
        /// <inheritdoc/>
        protected override void OnGotFocus(GotFocusEventArgs e)
        {
            base.OnGotFocus(e);

            if (e.NavigationMethod == NavigationMethod.Pointer ||
                e.NavigationMethod == NavigationMethod.Directional)
            {
                TrySetSelectionFromContainerEvent(e.Source, true);
            }
        }
Example #6
0
 /// <summary>
 /// Called when the <see cref="MenuItem"/> recieves focus.
 /// </summary>
 /// <param name="e">The event args.</param>
 protected override void OnGotFocus(GotFocusEventArgs e)
 {
     base.OnGotFocus(e);
     this.IsSelected = true;
 }
Example #7
0
 protected override void OnGotFocus(GotFocusEventArgs e)
 {
     base.OnGotFocus(e);
     _presenter.ShowCaret();
 }
        public void Focusing_Item_With_Pointer_Should_Select_It()
        {
            var target = new SelectingItemsControl
            {
                Template = this.Template(),
                Items = new[] { "foo", "bar" },
            };

            target.ApplyTemplate();

            var e = new GotFocusEventArgs
            {
                RoutedEvent = InputElement.GotFocusEvent,
                NavigationMethod = NavigationMethod.Pointer,
            };

            target.Presenter.Panel.Children[1].RaiseEvent(e);

            Assert.Equal(1, target.SelectedIndex);

            // GotFocus should be raised on parent control.
            Assert.False(e.Handled);
        }
        public void Focusing_Item_With_Tab_Should_Not_Select_It()
        {
            var target = new SelectingItemsControl
            {
                Template = this.Template(),
                Items = new[] { "foo", "bar" },
            };

            target.ApplyTemplate();

            var e = new GotFocusEventArgs
            {
                RoutedEvent = InputElement.GotFocusEvent,
                NavigationMethod = NavigationMethod.Tab,
            };

            target.Presenter.Panel.Children[1].RaiseEvent(e);

            Assert.Equal(-1, target.SelectedIndex);
        }
 /// <inheritdoc/>
 protected override void OnGotFocus(GotFocusEventArgs e)
 {
     base.OnGotFocus(e);
     this.TrySetSelectionFromContainerEvent(e.Source, true);
 }
        public void Focusing_Item_Should_Select_It()
        {
            var target = new SelectingItemsControl
            {
                Template = this.Template(),
                Items = new[] { "foo", "bar" },
            };

            target.ApplyTemplate();

            var e = new GotFocusEventArgs
            {
                RoutedEvent = InputElement.GotFocusEvent
            };

            target.Presenter.Panel.Children[1].RaiseEvent(e);

            Assert.Equal(1, target.SelectedIndex);
            Assert.False(e.Handled);
        }
Example #12
0
 /// <summary>
 /// Called before the <see cref="GotFocus"/> event occurs.
 /// </summary>
 /// <param name="e">The event args.</param>
 protected virtual void OnGotFocus(GotFocusEventArgs e)
 {
     IsFocused = e.Source == this;
 }
Example #13
0
 protected virtual void OnGotFocus(GotFocusEventArgs e)
 {
     this.IsFocused = e.OriginalSource == this;
     this.SetValue(IsTabFocusedProperty, e.KeyboardNavigated);
 }