This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, I know since 3.0 version, UI Virtualization has been added as a performance improvement. I detected when some elements are not rendered, because they're not in the ViewPort, the SizeToFit() method doesn't work as expected. This seems to be because the DiagramBounds Rect doesn't contain the elements that are not rendered (due to UI Virtualization). What I expect is that the SizeToFit() method, set the ViewPort to show all elements on the diagram. Another related question, Is there a way to disable UI Virtualization? I tried using VirtualizingPanel.IsVirtualizing="False" on the DiagramSurface, but it didn't help. Thanks, Ezequiel |
|
|
One more thing, is it possible to animate the SizeToFit()? It's not very comfortable for users how ViewPort is moved drastically to focus all elements. Probably, an animation will make this transition smoother. |
|
|
Hello Ezequiel The SizeToFit logic is supposed to get the diagram bounds of the whole model, not just the visible elements. There may be a bug in either calculating the bounds of the model in certain scenarios, or the element my be failing to be rendered. If you are able to send a repro project, I would be able to investigate into this further. The DiagramSurface uses very specialized virtualizing that we wrote, rather than using the VirtualizingPanel. In the next nightly build you will find an IsVirtualizing property on the DiagramSurface which you can use to disable virtualization. There isn't a way to animate our built in SizeToFit function, but you could create your own size to fit logic that you could use to animate the veiwport. The size to fit logic is very simple. Basically you compare the physical size of the DiagramSurface with the logical bounds of the model (accessible from the DiagramBounds property). Create 2 ratios between the physical and logical bounds - one for vertical and one for horizontal. Pick the smallest one to be the new Zoom level of the diagram. Then you calculate the vertical and horizontal positions to cause the zoomed diagram to be centered in the viewport. Once you have the desired vertical offset, horizontal offset and zoom values, animate the current values to these new values. (You can get the current viewport using the GetViewport() method). Apply these animated values via the DiagramSurface.Zoom property and the DiagramSurface.ScrollViewer.TranslateViewport method. I recommend starting with getting the zoom animating correctly, and then work on the centering logic. Let me know if you need help with calculating the desired values. Jason Fauchelle |
|