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
|
I have been testing out your WPF Diagrams library and working with the NodeGrouping sample project. I was wondering how I would programmatically set the ChildNode display text as well as the tooltip text? Thanks. |
|
|
Hi Eric, Thanks for trying out WPF Diagrams. To work with display text on nodes, we recommend using the Data property on the node model objects. To display text on the child nodes in the NodeGrouping sample, open DiagramStyle.xaml and find the ChildNodeStyle near the top of the file. Add a TextBlock between the Border tags, and bind the Text to the Data property:
Then in code, you can set the Data property of ChildNode instances to be a string which will be displayed on the node. The tooltip is a little more tricky. When you hover the mouse over the ChildNode, you'll see the mouse change to a drag cursor. This is because the mouse is over a MoveThumb control sitting in the node template. The visuals of the ChildNode (Green border) is sitting over the top of the MoveThumb, but has IsHitTestVisible set to false (which you can see in the ChildNodeStyle of DiagramStyle.xaml), so the mouse can't see it, and so tooltip wont work on it. So the best way to have a tooltip on the nodes is actually to set the tooltip on the MoveThumb control. To do this, add this custom MoveThumb style resource to the DiagramStyle.xaml file. This code alone will automatically be applied to all MoveThumb instances:
Here you can see I've set the ToolTip property on the parent Grid. This binds to the Element that the MoveThumb is attached to, grabs the Node which is the model object of the node-visual element, and then gets the Data property of that. If you want the tooltip to be different to the Data property, simply add a property to the ChildNode class to provide the tooltip value. Please let me know if you have further questions about this. -Jason Fauchelle |
|