This is a migrated thread and some comments may be shown as answers.

Set RadImageEditor Vertical and Horizonal Scrollbar Position in Code

1 Answer 171 Views
ImageEditor
This is a migrated thread and some comments may be shown as answers.
Lance
Top achievements
Rank 1
Lance asked on 27 Jun 2015, 02:34 AM

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

1 Answer, 1 is accepted

Sort by
0
Petya
Telerik team
answered on 01 Jul 2015, 05:25 PM
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
Tags
ImageEditor
Asked by
Lance
Top achievements
Rank 1
Answers by
Petya
Telerik team
Share this question
or