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

Resizing constraint for a subset of nodes in SfDiagram


I want to be able to determine whether a shape added to the diagram is going to have resizing constraints (so that the thumbs are not visible). This can be based on the Key property of the NodeViewModel. The problem that I have is that when I disable resizing for the selector like this (I put it in the constructor of the page containing the diagram):

var selector = (Diagram.SelectedItems as SelectorViewModel);
selector.SelectorConstraints = selector.SelectorConstraints & ~SelectorConstraints.Resizer;

The setting is applied to all nodes in the diagram. When I try to do it per node before the node is added to the diagram, resizing is not allowed, but the thumbs are still visible. Here is how I achieved it:

ObservableCollection<NodeViewModel> nodes = new ObservableCollection<NodeViewModel>();

NodeViewModel node = new NodeViewModel()
Constraints = NodeConstraints.Default & ~NodeConstraints.Resizable,
UnitWidth = 50,
UnitHeight = 50,
OffsetX = 100,
OffsetY = 100,
Shape = new RectangleGeometry() { Rect = new Rect(0, 0, 10, 10) },
ShapeStyle = Resources["shapeStyle"] as Style

Diagram.Nodes = nodes;

And when I tried applying the constraints after the node is added to the diagram in the ItemAdded event handler, the constraints have no effect of the node, even though I can see the Constraints property has changed.

Can you advise what the right approach is in order to achieve node-level control so that the resizing thumbs are not visible?

1 Reply

SS Suresh Shanmugam Syncfusion Team February 20, 2017 11:42 AM UTC

Hi Piotr, 
Requirement : “Need to disable the resizing and thumbs visibility for particular Node 
We have a support to achieve this requirement. We can enable or disable the resizer for the particular Node (by using Custom Property of the Node) in the ItemSelected Event. Please find the code snippet as below. 
Code Snippet : 

//Hook the ItemSelected Event 
(diagram.Info as IGraphInfo).ItemSelectedEvent += MainPage_ItemSelectedEvent; 
//We can use the any other Custom property instead of “Content” in NodeViewModel, which node want to hidden the visibility of resizing thumbs. 
private void MainPage_ItemSelectedEvent(object sender, DiagramEventArgs args) 
       var diagram = sender as SfDiagram; 
       var selector = diagram.SelectedItems as SelectorViewModel; 
       if (((args.Item as NodeViewModel).Content == "node2")) 
              selector.SelectorConstraints = selector.SelectorConstraints & ~SelectorConstraints.Resizer; 
              selector.SelectorConstraints = selector.SelectorConstraints | SelectorConstraints.Resizer; 

Suresh Shanmugam 

Live Chat Icon For mobile
Up arrow icon