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 Me again. This is not a very Wpf Diagram specific question so apologies in advance, but I'm using Caliburn.Micro and my ViewModel has a Diagram property which is data bound to the DiagramSurface in the view. Simple stuff right. However, after I update the Diagram property in the view model I need to tell the control to apply the layout. In the VM I dont know about the control in the view so how can I do this? Should I? In the sample LayourAlgorithym app, it uses a timer in the view to reapply the layout. I dont really want to do that as the user wont be changing the diagram - it's just generated once for them. Thanks |
|
|
Hello Jonesie The timer is only used by one of the layout algorithms - the Force Based Layout Algorithm. This is because it takes many iterations of the algorithm to reach a good layout, so we take advantage of this using a timer to create an animated effect. You won't need a timer for any of the other algorithms. Layout algorithms are model layer entities which means they don't need the view in order to work. If you just want to lay out the diagram in the model (when the Diagram property is updated), you can simply call the Run method of the layout algorithm instance and pass in the diagram model. The only difference between calling the DiagramSurface.ApplyLayoutAlgorithm method or directly calling ILayoutAlgorithm.Run is a couple of null checks and a call to DiagramSurface.TakeSnapshot. TakeSnapshot is for adding a snapshot of the diagram to the undo stack. This won't be necessary in your scenario. Jason Fauchelle |
|
|
Awesome, that worked. Cheers |
|