Keyboard focus

1 Answer 18 Views
ChartView
Jason D
Top achievements
Rank 1
Veteran
Jason D asked on 24 Jan 2024, 09:43 PM
I want to zoom and pan the chart using the keyboard with the plus/minus and cursor keys. This works for the Map Control. However, I'm unable to use the mouse to set the focus on the chart to receive keys. I can tab to the chart, not clicking the mouse does not work and the focus remains on the currently focused element.

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 25 Jan 2024, 02:00 PM

Hello Jason,

In WPF mostly controls that you can interact with (like TextBox or Button) are automatically focused on click. To allow this with the chart control, you can manually call its Focus method on MouseLeftButtonDown.

  private void RadCartesianChart_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
  {
      var chart = (RadCartesianChart)sender;
      chart.Focus();
  }

Regards,
Martin Ivanov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Jason D
Top achievements
Rank 1
Veteran
commented on 25 Jan 2024, 11:47 PM

Thanks, that seems to work. However, I'm struggling to control the panning with the keyboard. Ideally, using the cursor arrow keys would pan the chart the same amount as clicking the arrows on a scroll bar. I can find the PanZoomBar of an axis, but the Value is 0, even after zooming in. I had hoped to adjust the Value in increments of SmallChange.

For Zooming, I use the plus/minus keys to adjust the Zoom property by incremements of 1. Ideally this would match the zoom increment when using the mouse wheel, but I'm not sure how to do that.

Martin Ivanov
Telerik team
commented on 26 Jan 2024, 02:49 PM

To adjust the panning, you can set the PanOffset property of the chart control.
Tags
ChartView
Asked by
Jason D
Top achievements
Rank 1
Veteran
Answers by
Martin Ivanov
Telerik team
Share this question
or