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
|
This is probably more of a general WPF question, but I'm hoping someone has done this before with FlowDiagrams. From a custom Node class and style, I'm able to double-click and have a separate Window open that's specific to that Node, based on code from here: This example actually works pretty well, you can bind whatever properties you want in the Window that opens, because it's View-First and the bindings are set up when the ViewModel is created. BUT: Using custom Nodes, it's ViewModel-First, because Nodes are ViewModels. Where it goes sideways is that even though I can make the Window open (and close), no matter what tricks I try and pull in the XAML, I can't get the Window to bind to any properties in the custom Node. Anyone got any suggestions on making this work, or is there a different way? Damien |
|
|
I should also have said I'd like to avoid putting anything in code-behind or inside the ViewModel that knows about the Window. I'm beginning to think I might not have a choice though. Working functionality over abstract purity... |
|
|
Hello Damien When you detect a double click on a node element, you are be able to get the IDiagramNode model object similar to what I mentioned in the answer to your previous forum question. (You can get the DiagramNodeElement, and then get the IDiagramNode model via the Node property). You should then be able to use this IDiagramNode model object as part of the DataContext/View of the Window that opens. Though I am not familiar with the technique you linked to, so if you are still having troubles with this, you can send us your current project - or a cut down version of it, and I'd be happy to find a good way to do this for you. You can either attach a project to a forum reply, or send it to jason@mindscape.co.nz Jason Fauchelle |
|
|
Thanks Jason. I tried that with Windows having their DataContext bound to the ViewModel, and I could never get them to open. As of 10 minutes ago I chucked the technique I linked to as well, and went with a small templated broker object that sets a specific Window class's DataContext to a specific Node when a property is set. It's not perfect MVVM but it works, it's 25 lines of template code and the broker object only exists when that property is set. That'll do. Damien |
|
|
Great to hear you found a good-enough work around for this with only a small amount of code! |
|
|
I'll try and package it up into a small example and attach it. Might be useful for someone else. |
|