private void AddNewRow(DataRowViewModel dataRowViewModel) { var newRow = new DataRowView { DataContext = dataRowViewModel, DataCellWidth = DataCellWidth }; // Adjust header cells' width var binding = new Binding("ActualWidth") { Source = newRow.PART_NameCell }; PART_HeaderRow.PART_NameCell.SetBinding(WidthProperty, binding); PART_MaxRow.PART_NameCell.SetBinding(WidthProperty, binding); PART_MinRow.PART_NameCell.SetBinding(WidthProperty, binding); // Add separator PART_ItemsStack.Children.Add(new Separator()); // Add new row PART_ItemsStack.Children.Add(newRow); if (PART_AutoScrollCheckBox.IsChecked != null && (bool)PART_AutoScrollCheckBox.IsChecked) { PART_ScrollViewer.ScrollToBottom(); } }
/// <summary> /// Handles <see cref="GamePad.AxisDownEvent"/> when the drop down is open. /// </summary> private void OnGamePadAxisDown_DropDownOpen(GamePadDevice device, GamePadAxis axis, Single value, Boolean repeat, ref RoutedEventData data) { if (GamePad.UseAxisForDirectionalNavigation) { if (GamePad.DirectionalNavigationAxisX == axis || GamePad.DirectionalNavigationAxisY == axis) { var direction = device.GetJoystickDirectionFromAxis(axis); switch (direction) { case GamePadJoystickDirection.Up: MoveItemFocus(-1); break; case GamePadJoystickDirection.Down: MoveItemFocus(1); break; case GamePadJoystickDirection.Left: if (PART_ScrollViewer != null) { PART_ScrollViewer.HandleKeyScrolling(Key.Left, ModifierKeys.None, ref data); } break; case GamePadJoystickDirection.Right: if (PART_ScrollViewer != null) { PART_ScrollViewer.HandleKeyScrolling(Key.Right, ModifierKeys.None, ref data); } break; } data.Handled = true; } } }
/// <summary> /// Handles <see cref="GamePad.ButtonDownEvent"/> when the drop down is open. /// </summary> private void OnGamePadButtonDown_DropDownOpen(GamePadDevice device, GamePadButton button, Boolean repeat, ref RoutedEventData data) { if (GamePad.ConfirmButton == button) { SelectFocusedItem(); IsDropDownOpen = false; data.Handled = true; } else if (GamePad.CancelButton == button) { IsDropDownOpen = false; data.Handled = true; } else if (GamePad.TabButton == button) { PerformTabNavigation(Key.Tab, ModifierKeys.None); data.Handled = true; } else if (GamePad.ShiftTabButton == button) { PerformTabNavigation(Key.Tab, ModifierKeys.Shift); data.Handled = true; } else { if (!GamePad.UseAxisForDirectionalNavigation) { switch (button) { case GamePadButton.DPadUp: MoveItemSelection(-1); break; case GamePadButton.DPadDown: MoveItemSelection(1); break; case GamePadButton.DPadLeft: if (PART_ScrollViewer != null) { PART_ScrollViewer.HandleKeyScrolling(Key.Left, ModifierKeys.None, ref data); } break; case GamePadButton.DPadRight: if (PART_ScrollViewer != null) { PART_ScrollViewer.HandleKeyScrolling(Key.Right, ModifierKeys.None, ref data); } break; } data.Handled = true; } } }
/// <inheritdoc/> protected override void OnGamePadButtonDown(GamePadDevice device, GamePadButton button, Boolean repeat, ref RoutedEventData data) { if (GamePad.ConfirmButton == button) { var listBoxItem = ItemsControlUtil.FindContainer <ListBoxItem>(this, data.OriginalSource); if (listBoxItem != null) { HandleItemClicked(listBoxItem); data.Handled = true; } } else { if (!GamePad.UseAxisForDirectionalNavigation) { switch (button) { case GamePadButton.DPadLeft: if (PART_ScrollViewer != null) { PART_ScrollViewer.HandleKeyScrolling(Key.Left, ModifierKeys.None, ref data); } data.Handled = true; break; case GamePadButton.DPadRight: if (PART_ScrollViewer != null) { PART_ScrollViewer.HandleKeyScrolling(Key.Right, ModifierKeys.None, ref data); } data.Handled = true; break; case GamePadButton.DPadUp: if (SelectionMode == SelectionMode.Single) { MoveSelectedItem(FocusNavigationDirection.Up); } data.Handled = true; break; case GamePadButton.DPadDown: if (SelectionMode == SelectionMode.Single) { MoveSelectedItem(FocusNavigationDirection.Down); } data.Handled = true; break; } } } base.OnGamePadButtonDown(device, button, repeat, ref data); }
private void opacityAnim_Completed(object sender, EventArgs e) { PART_ContentScreenshot.Opacity = 0; PART_ContentScreenshot.Source = null; PART_Content.Opacity = 1; PART_Content.IsHitTestVisible = true; PART_ScrollViewer.ScrollToHorizontalPixel(0); PART_ScrollViewer.ScrollToVerticalPixel(0); }
/// <summary> /// Handles <see cref="GamePad.ButtonDownEvent"/> when the drop down is open. /// </summary> private void OnGamePadButtonDown_DropDownOpen(GamePadDevice device, GamePadButton button, Boolean repeat, RoutedEventData data) { if (GamePad.ConfirmButton == button) { SelectFocusedItem(); IsDropDownOpen = false; data.Handled = true; } else if (GamePad.CancelButton == button) { IsDropDownOpen = false; data.Handled = true; } else if (GamePad.TabButton == button) { PerformTabNavigation(Key.Tab, ModifierKeys.None); data.Handled = true; } else if (GamePad.ShiftTabButton == button) { PerformTabNavigation(Key.Tab, ModifierKeys.Shift); data.Handled = true; } else { switch (button) { case GamePadButton.LeftStickUp: MoveItemFocus(-1); data.Handled = true; break; case GamePadButton.LeftStickDown: MoveItemFocus(1); data.Handled = true; break; case GamePadButton.LeftStickLeft: PART_ScrollViewer?.LineLeft(); data.Handled = true; break; case GamePadButton.LeftStickRight: PART_ScrollViewer?.LineRight(); data.Handled = true; break; } } }
private void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Add) { foreach (Message item in e.NewItems) { PART_MessageStackPanel.Children.Add(new MessageCard { Message = item.Text, Author = item.Author, Date = item.Date, HeadUri = item.HeadUri }); } PART_ScrollViewer.ScrollToEnd(); // Upexpected: The ScrollToEnd() method will trigger the IsArrivedTop property change, and cause the LoadPreviousMessages() method to be called. } }
/// <inheritdoc/> protected override void OnGamePadButtonDown(GamePadDevice device, GamePadButton button, Boolean repeat, RoutedEventData data) { if (GamePad.ConfirmButton == button) { var listBoxItem = ItemsControlUtil.FindContainer <ListBoxItem>(this, data.OriginalSource); if (listBoxItem != null) { HandleItemClicked(listBoxItem); data.Handled = true; } } else { switch (button) { case GamePadButton.LeftStickLeft: PART_ScrollViewer?.LineLeft(); data.Handled = true; break; case GamePadButton.LeftStickRight: PART_ScrollViewer?.LineRight(); data.Handled = true; break; case GamePadButton.LeftStickUp: if (SelectionMode == SelectionMode.Single) { MoveSelectedItem(FocusNavigationDirection.Up); } data.Handled = true; break; case GamePadButton.LeftStickDown: if (SelectionMode == SelectionMode.Single) { MoveSelectedItem(FocusNavigationDirection.Down); } data.Handled = true; break; } } base.OnGamePadButtonDown(device, button, repeat, data); }
/// <inheritdoc/> protected override void OnGamePadAxisDown(GamePadDevice device, GamePadAxis axis, Single value, Boolean repeat, ref RoutedEventData data) { if (GamePad.UseAxisForDirectionalNavigation && (axis == GamePad.DirectionalNavigationAxisX || axis == GamePad.DirectionalNavigationAxisY)) { var direction = device.GetJoystickDirectionFromAxis(axis); switch (direction) { case GamePadJoystickDirection.Left: if (PART_ScrollViewer != null) { PART_ScrollViewer.HandleKeyScrolling(Key.Left, ModifierKeys.None, ref data); } break; case GamePadJoystickDirection.Right: if (PART_ScrollViewer != null) { PART_ScrollViewer.HandleKeyScrolling(Key.Right, ModifierKeys.None, ref data); } break; case GamePadJoystickDirection.Up: if (SelectionMode == SelectionMode.Single) { MoveSelectedItem(FocusNavigationDirection.Up); } break; case GamePadJoystickDirection.Down: if (SelectionMode == SelectionMode.Single) { MoveSelectedItem(FocusNavigationDirection.Down); } break; } data.Handled = true; } base.OnGamePadAxisDown(device, axis, value, repeat, ref data); }
/// <inheritdoc/> protected override void OnKeyDown(KeyboardDevice device, Key key, ModifierKeys modifiers, RoutedEventData data) { switch (key) { case Key.Space: case Key.Return: if (key == Key.Return && !GetValue <Boolean>(KeyboardNavigation.AcceptsReturnProperty)) { break; } var listBoxItem = ItemsControlUtil.FindContainer <ListBoxItem>(this, data.OriginalSource); if (listBoxItem != null) { HandleItemClicked(listBoxItem); data.Handled = true; } break; case Key.Left: PART_ScrollViewer?.LineLeft(); data.Handled = true; break; case Key.Right: PART_ScrollViewer?.LineRight(); data.Handled = true; break; case Key.Up: if (SelectionMode == SelectionMode.Single) { MoveSelectedItem(FocusNavigationDirection.Up, modifiers); } data.Handled = true; break; case Key.Down: if (SelectionMode == SelectionMode.Single) { MoveSelectedItem(FocusNavigationDirection.Down, modifiers); } data.Handled = true; break; case Key.Home: var firstItem = ItemsControlUtil.GetFirstItem <ListBoxItem>(this, PART_ScrollViewer); if (firstItem != null && firstItem.Focus()) { HandleItemClickedAndScrollIntoView(firstItem); } data.Handled = true; break; case Key.End: var lastItem = ItemsControlUtil.GetLastItem <ListBoxItem>(this, PART_ScrollViewer); if (lastItem != null && lastItem.Focus()) { HandleItemClickedAndScrollIntoView(lastItem); } data.Handled = true; break; case Key.PageUp: var pageUpTarget = ItemsControlUtil.GetPageUpNext <ListBoxItem>(this, PART_ScrollViewer); if (pageUpTarget != null && pageUpTarget.Focus()) { HandleItemClickedAndScrollIntoView(pageUpTarget, false); } data.Handled = true; break; case Key.PageDown: var pageDownTarget = ItemsControlUtil.GetPageDownNext <ListBoxItem>(this, PART_ScrollViewer); if (pageDownTarget != null && pageDownTarget.Focus()) { HandleItemClickedAndScrollIntoView(pageDownTarget, false); } data.Handled = true; break; } base.OnKeyDown(device, key, modifiers, data); }
/// <summary> /// Handles <see cref="Keyboard.KeyDownEvent"/> when the drop down is open. /// </summary> private void OnKeyDown_DropDownOpen(KeyboardDevice device, Key key, ModifierKeys modifiers, RoutedEventData data) { switch (key) { case Key.Tab: PerformTabNavigation(key, modifiers); data.Handled = true; break; case Key.Escape: IsDropDownOpen = false; data.Handled = true; break; case Key.Return: SelectFocusedItem(); IsDropDownOpen = false; data.Handled = true; break; case Key.Up: MoveItemFocus(-1); data.Handled = true; break; case Key.Down: MoveItemFocus(1); data.Handled = true; break; case Key.PageUp: var pageUpTarget = ItemsControlUtil.GetPageUpNext <ComboBoxItem>(this, PART_ScrollViewer); if (pageUpTarget != null && pageUpTarget.Focus()) { ItemsControlUtil.ScrollItemIntoView <ComboBoxItem>(this, PART_ScrollViewer, pageUpTarget, false); } data.Handled = true; break; case Key.PageDown: var pageDownTarget = ItemsControlUtil.GetPageDownNext <ComboBoxItem>(this, PART_ScrollViewer); if (pageDownTarget != null && pageDownTarget.Focus()) { ItemsControlUtil.ScrollItemIntoView <ComboBoxItem>(this, PART_ScrollViewer, pageDownTarget, false); } data.Handled = true; break; case Key.Home: var firstItem = ItemsControlUtil.GetFirstItem <ComboBoxItem>(this, PART_ScrollViewer); if (firstItem != null && firstItem.Focus()) { ItemsControlUtil.ScrollItemIntoView <ComboBoxItem>(this, PART_ScrollViewer, firstItem); } data.Handled = true; break; case Key.End: var lastItem = ItemsControlUtil.GetLastItem <ComboBoxItem>(this, PART_ScrollViewer); if (lastItem != null && lastItem.Focus()) { ItemsControlUtil.ScrollItemIntoView <ComboBoxItem>(this, PART_ScrollViewer, lastItem); } data.Handled = true; break; case Key.Left: PART_ScrollViewer?.LineLeft(); data.Handled = true; break; case Key.Right: PART_ScrollViewer?.LineRight(); data.Handled = true; break; } }
private void ListView_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e) { PART_ScrollViewer.ScrollToHome(); }
private void PART_HorizontalScrollBar_Scroll(object sender, ScrollEventArgs e) { PART_ScrollViewer.ScrollToHorizontalPixel(e.NewValue * PART_ScrollViewer.ScrollableWidth); }
private void PART_VerticalScrollBar_Scroll(object sender, ScrollEventArgs e) { PART_ScrollViewer.ScrollToVerticalPixel(e.NewValue * PART_ScrollViewer.ScrollableHeight); }