My application shows a series of diagrams and implements a back-forward functionality on them. I do this by changing GraphSource.
However, I would like to preserve the position and zoom of the diagrams as the user goes back and forth. I'm trying to do this by setting the Position and Zoom properties on RadDiagram. However, the view is not correctly restored. I've verified that the correct position and zoom values are being set.
What is the recommended way to do this?
5 Answers, 1 is accepted
Setting the Zoom and Position properties should work. Could you please elaborate more on your implementation, which other properties you use? What goes wrong exactly, is it possible for you to provide some snapshots or to isolate a small sample reproducing the problem ? This way we would be better able to advice you. Thank you for your cooperation.
Regards,Petar Mladenov
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
I am encountering the same problem.
Let's say I store the Position (point) and Zoom (double) properties to variables somewhere, then move the diagram around, then try to assign the saved property to the Diagram control, the restored position is NOT correct visually. It is correct value, but the offset (visually) is incorrect.
If I don't modify the Zoom property, the position works fine. I think Zoom is introducing an offset that is not being handled correctly. Or, the position is not being updated properly after zoom.
The problem seems to be related to the zoom position. Zooming in and out does not update the Position property.
Hello Dax,
Problem with zoom is that when you zoom with Mouse, the mouse position participates in the calculation and this can move the viewport. ViewPort is not saved / restored during save load. Here is a possible code you can use.
private double savedZoomFactor;
Point savedDiagramPosition;
private void Save(object sender, RoutedEventArgs e)
{
savedZoomFactor = radDiagram.Zoom;
savedDiagramPosition = radDiagram.Viewport.TopLeft;
}
private void Load(object sender, RoutedEventArgs e)
{
radDiagram.BringIntoView(savedDiagramPosition, savedZoomFactor);
}
We would appreciate any feedback regarding this code. We will also try to include it in our documentation.
Regards,
Petar Mladenov
Progress Telerik
Hi Petar,
Thank you so much! That did it. Haha - it was driving me crazy.
Might I suggest that when the docs are updated, this be made into a small how-to. Or at least a section in the pan/zoom article.
Thanks again,
Dax
Hello Dax,
I am glad to know you have resolved your issue. Yes, at least it will be added in the pan / zoom article.
Regards,
Petar Mladenov
Progress Telerik