Set RadImageEditor Vertical and Horizonal Scrollbar Position in Code

2 posts, 0 answers
  1. Lance
    Lance avatar
    1 posts
    Member since:
    Jan 2009

    Posted 26 Jun 2015 Link to this post

    I am needing to set the Vertical and Horizontal Scrollbar position each time I load and display a new image with the RadImageEditor control.  It looks like by default, that the scrollbars do not reset themselves to the top for the Vertical and to the left for the Horizontal bars when a new image is loaded and displayed if the image has been zoomed in and the scrollbars are not at these positions.  

    I see that there is a Property on the control named ScrollViewerName, that is a string of the name of the ScollViewer, but I am not sure how to gain access to the ScrollViewer of the control to change the values.

    Any help would be greatly appreciated.

     

    Lance

  2. Petya
    Admin
    Petya avatar
    975 posts

    Posted 01 Jul 2015 Link to this post

    Hello Lance,

    One of the possible approaches you can adopt is to extract the template of RadImageEditor which will give you access to the ScrollViewer.

    As an alternative and slightly hacky approach, you can use the ChildrenOfType extension to access the scroll viewer. For example, try subscribing to the CommandExecuted event like this:
    void ImageEditor_CommandExecuted(object sender, Telerik.Windows.Media.Imaging.ImageEditorCommands.ImageCommandExecutedEventArgs e)
    {
        if (e.Command is OpenImageCommand)
        {
            ScrollViewer scroll = this.ImageEditorUI.ImageEditor.ChildrenOfType<ScrollViewer>().First();
            scroll.ScrollToHorizontalOffset(0);
            scroll.ScrollToVerticalOffset(0);
        }
    }

    I hope this helps.

    Regards,
    Petya
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. DevCraft banner
Back to Top