Scrolling with keyboard -- set focus to scrollbar?

A forum dedicated to WPF version of LightningChart Ultimate.

Moderator: Arction_LasseP

kse
Posts: 1
Joined: Fri Jun 22, 2018 2:32 pm

Scrolling with keyboard -- set focus to scrollbar?

Post by kse » Fri Jun 22, 2018 2:41 pm

I have a ViewXY sample data series and a horizontal scroll bar. I would like the user to be able to use keyboard keys to scroll the graph horizontally without having to click on the scrollbar first (i.e. they should work any time the window has focus... the graph is the only thing in this window.) What's the best way to do this? It doesn't seem possible to set focus to the scrollbar or route the events through LightningChart via the normal ways this is done in WPF.

Bonus question: is there a good way to enable zooming for both X and Y simultaneously, maintaining the current aspect ratio?

ArctionKestutis
Posts: 383
Joined: Mon Mar 14, 2016 9:22 am

Re: Scrolling with keyboard -- set focus to scrollbar?

Post by ArctionKestutis » Mon Jun 25, 2018 10:58 am

Hi,

At the moment LightningChart's ScrollBar focus could be set only by clicking on it. And there is no easy way mimic mouse click on WPF. I will add as feature request 'manual set of ScrollBar focus'.
As workaround, you can set chart focus and subscribe to KeyDown event:

Code: Select all

        private void _chart_Loaded(object sender, RoutedEventArgs e)
        {
            _chart.Focus();
            _chart.KeyDown += _chart_KeyDown;
        }
In event handler just modify ScrollBar value accordingly.

Most general way to keep X and Y in sync is to subscribe to Axis.RangeChanged event and modify another axis accordingly (with Axis.SetRange). Note, don't forgot to unsubscribe from corresponding event during range set.
There is also option in LightningChart: manually set the preferred ratio with _chart.ViewXY.ZoomPanOptions.AspectRatioOptions.AspectRatio. Option AspectRatioOptions.AspectRatio controls the X/Y (or longitude / latitude in maps) ratio. Set it to Off to allow X and Y axis range setting individually. By setting the aspect ratio to Manual, use the ManualAspectRatioWH property to set the preferred ratio. The zooming operations will follow aspect ratio setting. Check is this that you need.

All the best.