/// <inheritdoc/> protected override void OnGotFocus(GotFocusEventArgs e) { base.OnGotFocus(e); if (e.NavigationMethod == NavigationMethod.Directional) { e.Handled = UpdateSelectionFromEventSource(e.Source); } }
/// <inheritdoc/> protected override void OnGotFocus(GotFocusEventArgs e) { if (e.NavigationMethod == NavigationMethod.Directional) { e.Handled = UpdateSelectionFromEventSource( e.Source, true, (e.InputModifiers & InputModifiers.Shift) != 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; } }
/// <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; }
/// <inheritdoc/> protected override void OnGotFocus(GotFocusEventArgs e) { base.OnGotFocus(e); if (e.NavigationMethod == NavigationMethod.Pointer || e.NavigationMethod == NavigationMethod.Directional) { TrySetSelectionFromContainerEvent(e.Source, true); } }
/// <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; }
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); }
protected virtual void OnGotFocus(GotFocusEventArgs e) { this.IsFocused = e.OriginalSource == this; this.SetValue(IsTabFocusedProperty, e.KeyboardNavigated); }