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.
Unfortunately, activation email could not send to your email. Please try again.

Resizing constraint for a subset of nodes in SfDiagram

Thread ID:

Created:

Updated:

Platform:

Replies:

128960 Feb 17,2017 01:43 PM Feb 20,2017 06:42 AM UWP 1
loading
Tags: SfDiagram
PH
Asked On February 17, 2017 01:43 PM

Hi

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
};

nodes.Add(node);
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?




Suresh Shanmugam [Syncfusion]
Replied On February 20, 2017 06:42 AM

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; 
       } 
       else 
       { 
              selector.SelectorConstraints = selector.SelectorConstraints | SelectorConstraints.Resizer; 
       } 
} 
 

Regards, 
Suresh Shanmugam 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;