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

How to find diagram's scrollViewer

3 Answers 129 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Yuanhong
Top achievements
Rank 1
Yuanhong asked on 16 Jan 2019, 12:32 AM

In the recent project, I want to control the scrollViewer on the diagram and set the offset of the scrollViewer. I looked at the API and found that the offset property is not public. What should I do?

Any help would be appreciated.


3 Answers, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 18 Jan 2019, 12:09 PM
 Hello Yuanhong,

I am not sure how you have added the ScrollViewer to the RadDiagram control but the ScrollViewer itself has a ScrollToHorizontalOffset() and ScrollToVerticalOffset() methods which you can use to change the offset. May I ask you to elaborate more on your application set up so I could better understand your scenario.

Regards,
Dinko
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Yuanhong
Top achievements
Rank 1
answered on 21 Jan 2019, 12:52 AM

The method of finding the scrollviewer in the listbox is as follows:

ScrollViewer _listboxScrollViewer1 = this.listbox.ChildrenOfType<ScrollViewer>().FirstOrDefault();

but,RadDiagram can't find Scrollviewer by this way.


0
Dinko | Tech Support Engineer
Telerik team
answered on 23 Jan 2019, 02:21 PM
Hi Yuanhong,

Thank you for elaborating your approach.

When the ScrollViewer.HorizontalScrollBarVisibility and ScrollViewer.VerticalScrollBarVisibility are set to Visible ScrollBar will be added to the RadDiagram, not ScrollViewer. That is why the ChildrenOfType<T>() will return null. The ScrollBar provide Value property which can be set to change the position of the thumb. For example, you can subscribe to the loaded event of the RadDiagram and using the mentioned extension method you can get the horizontal and vertical scrollbars. The following code snippet gets the vertical scrollbar and set the value of 50 where the Maximum property is 100 on my side.
private void Diagram_Loaded(object sender, RoutedEventArgs e)
{
    var diagram = sender as RadDiagram;
    var verticalOrientation = diagram.ChildrenOfType<ScrollBar>().FirstOrDefault(x=>x.Orientation== Orientation.Vertical);
    verticalOrientation.Value = 50;
}

Regards,
Dinko
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Diagram
Asked by
Yuanhong
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Yuanhong
Top achievements
Rank 1
Share this question
or