We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Node resize

I am using the DiagarmModel with DirectedTreeLayout .
I set the same width/height for all nodes in tree.

Is there a way to display the nodes so that the node will resize to fit the node label?

Thanks,

Mary


1 Reply

RT Ramya Thirugnanam Syncfusion Team January 12, 2012 05:17 PM UTC

Hi Mary,

With regards to Node resizing on its Label changes, this can be achieved by specifying the Size of Node as double.NaN. Node Size will be changed according to its Label size. Please refer to the code Snippet for this. Please refer to the sample which represent your requirement from attachment.

Sample Details:
In that sample, we have created a DirectedTreeLayout. Please Select the Node and Start Editing the provided Text box, it updates the Label of the Selected Node. The Node resizes on its Label changes.

Code Snippet:
//Register the Label changed event
diagarmView.NodeLabelChanged += new LabelChangedEventHandler(diagarmView_NodeLabelChanged);

void diagarmView_NodeLabelChanged(object sender, LabelRoutedEventArgs evtArgs)
{
Node curnode = (evtArgs.Node as Node);
//For resolving the Node resizing on content changes
curnode.Width = double.NaN;
curnode.Height = double.NaN;
curnode.UpdateLayout();
//solution to overcome the restriction of basic operation like Node resizing, rotating, automatic layouts.
curnode.Width = curnode.ActualWidth;
curnode.Height = curnode.ActualHeight;
}
If this response does not satisfy your requirement, please get back us with more details of your expectations.

Please let us know if you have any concerns.
Regards,
Ramya




NodeResizes_45baafbf.zip

Loader.
Live Chat Icon For mobile
Up arrow icon