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 wanted to implement different coloring for the node when the mouse button is still being pressed, or being dragging, and also another coloring for the node when it is being selected. How can I implement that in current selection event, because I noticed that the selection changed event on the node is being fired once we click on it and the mouse button is still being pressed. Currently I am only able to get the Selected Node appear to be different by checking the IsSelected property that we stored in the Node.Data (basically a MVVM ViewModel). I do it in the DataTemplate of the node. Any idea how to achieve that behaviour? Thanks. |
|
|
Hello Just to clarify, you want to change the color of the node when the mouse is pressed over the node, and then change the color to be different when the mouse is released and the node is selected. I'll probably need to add another property or event to support this. Are you using WPF Diagrams 1.0 or 2.0? - Jason |
|
|
Yea correct, that is the behaviour we wanted to implement. We're using Diagrams1.0 now, but we might want to migrate to 2.0 if there's no big changes to our current code. I tried to use 2.0 yesterday and somehow the code doesn't compile due to some errors. I believe there are some changes involved in the Connection template, which is no longer used in 2.0. I'll get back to you more on the migration issues in future. Right now, maybe we should stick to the current version first if that's ok for you. |
|
|
Hello I have managed to change the color of the node when the mouse is pressed, and then change it again when the mouse is released and the node is selected by using these triggers in the node template:
<DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType={x:Type ms:DiagramNodeElement}}}" Value="True"> <DataTrigger Binding="{Binding IsMouseCaptureWithin, RelativeSource={RelativeSource AncestorType={x:Type ms:DiagramNodeElement}}}" Value="True"> The first trigger uses a binding to the IsSelected property on the DiagramNodeElement to change the color to red. The second trigger uses a binding to the IsMouseCaptureWithin property which is true when the mouse is pressed on the MoveThumb because it captures the mouse. you should be able to replace the first trigger with whatever you are using to listen to your IsSelected property in the ViewModel. The order of these triggers is important for it to work. It does not work in readonly mode though. This technique works in both WPF Diagrams versions. Let me know if this is what you needed. |
|