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
|
Hello, i have a WPF View, in an MVVM architecture, where data is represented with a DataTemplate which contains a DiagramSurface. Here is the DataTemplate:
The tabcontrol which uses the DataTemplate:
I want to use the automatic layout function of WPF Diagrams, the trouble is, that i haven't found a way to get the instance of the actual DiagramSurface to apply the layout. Because of the MVVM Architecture i can only use Bindings. I would be very happy if you could show me a solution for this Problem. Best regards, Jan |
|
|
Hello Jan Thanks for trying out our WPF Diagrams framework. It is certainly tricky to call the DiagramSurface.ApplyLayoutAlgorithm method in an MVVM architecture, but fortunately, you may not need to. All the layout algorithms have a Run method which you can use in your model. Simply create an instance of the layout algorithm you want to apply, and then Call its Run method by passing in your CurrentFlowDiagramModel value. This conforms to the MVVM pattern because layout algorithms are model objects that just apply logic to modify another model object. The only downside to this is the ApplyLayoutAlgorithm method has the added bonus of adding another frame to the undo stack. But calling the Run method on a layout algorithm does not. This is only a concern if you are applying a layout algorithm as the direct result of a user action, and want them to have the option to undo the action. If you do need to allow the user to undo a layout algorithm step, then the best approach would be to create an attached property which you can bind to, which will encapsulate the action of calling the ApplyLayoutAlgorithm method. This is also an MVVM friendly technique which is often used in this scenario. Let me know if you have questions about any of this! -Jason Fauchelle |
|