RadTimeBar initial Zoom + Keyboard zoom

3 posts, 0 answers
  1. Tulio
    Tulio avatar
    6 posts
    Member since:
    Jul 2017

    Posted 13 Sep Link to this post

    Hi!

     

    I have two issues with the zoom for the timebar (I am plotting a RadColumnSparkLine in it)

     

    1) I want to be able to set the initial zoom level (I have the period start to end for 3 days). I want the initial zoom to be for 1 day and then the user can zoom out to see the whole 3 days period if he wants.

     

    2) Allow keyboard integration so the user can zoom with Ctrl and + and zoom out with Ctrl and -

     

    Thanks!

  2. Stefan
    Admin
    Stefan avatar
    774 posts

    Posted 18 Sep Link to this post

    Hi Tulio,

    In order to set the initial zoom level of the control, you can use the MinZoomRange of the control as per your needs.
    this.zoomTimeBar.MinZoomRange = new System.TimeSpan(24, 0, 0);

    Then, in order to define the required keyboard behavior, you can subscribe to the KeyDown event of the control as demonstrated below.
    this.AddHandler(RadTimeBar.KeyDownEvent,
    new KeyEventHandler(zoomTimeBar_KeyDown), true);

    Since you need to use the Ctrl modifier in conjunction with the Add and Subtract keys, the event handler would look similar to the code snippet below.
    private void zoomTimeBar_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
    {
        if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
        {
            if (e.Key == Key.Add)
            {
                this.zoomTimeBar.MinZoomRange += new System.TimeSpan(24, 0, 0);
            }
            else if (e.Key == Key.Subtract)
            {
                this.zoomTimeBar.MinZoomRange -= new System.TimeSpan(24, 0, 0);
            }
        }
    }

    I hope that these suggestions correspond to your needs. Can you please give them a try? I am staying at your disposal in case further assistance is needed.

    Best Regards,
    Stefan X1
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
  3. Tulio
    Tulio avatar
    6 posts
    Member since:
    Jul 2017

    Posted 21 Sep Link to this post

    Thanks! Will try that!
Back to Top