How to resize the "node area" according to the space needed by a custom UserControl?

Hello,

I created an UserControl with a TextBox inside (it's just for explaining my problem, I'll use a more elaborate UserControl).

When I'm typing inside this TextBox, it expands ... but not the area of the node. So my TextBox is clipped...

What I'm looking to do: 

How to resize the "node area" according to the space needed by a custom UserControl?


Thank you in advance.


3 Replies 1 reply marked as answer

KR Karkuvel Rajan Shanmugavel Syncfusion Team September 6, 2021 07:14 AM UTC

Hi Rodrigue, 
 
Thanks for contacting Syncfusion support. 
 
Requirement: How to dynamically change the node size according to the space needed by a custom UserControl? 
 
We have analyzed your requirement. In General, if we want to change the node size then we have to change the node size through any of the changed event. For example if you use textbox then using the TextChanged event of the TextBox to change the node size. For this example please find the code example below. 
 
Code example:  
 
 
        private void UserTextBox_TextChanged(object sender, TextChangedEventArgs e) 
        { 
            TextBox textbox = sender as TextBox; 
 
            double textboxwidth = textbox.Text.Length * (textbox.FontSize * .50); 
 
            // For this we need to set the Content of the node as node like below. 
            // node.Content = node; 
 
            (textbox.DataContext as NodeViewModel).UnitWidth = textboxwidth; 
 
        } 
 
 
Regards, 
Karkuvel Rajan S 


Marked as answer

PE Peter September 7, 2021 09:12 AM UTC

Thank you very much. It works!




KR Karkuvel Rajan Shanmugavel Syncfusion Team September 7, 2021 11:52 AM UTC

Hi Rodrigue, 
 
Most welcome, let us know if need any other assistance. 
 
Regards, 
Karkuvel Rajan S 


Loader.
Up arrow icon