This is a migrated thread and some comments may be shown as answers.

Cancel a connection based on the target type.

3 Answers 61 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 07 Dec 2013, 09:40 PM
Hi,

I am new to Rad Controls/Diagram and would like some help if possible.

What I would like to do is cancel a connection between two items within the diagram based on the target's type.

Is this possible, if so, how would I go about it?

Thanks
Paul.

3 Answers, 1 is accepted

Sort by
0
Accepted
Pavel R. Pavlov
Telerik team
answered on 11 Dec 2013, 12:14 PM
Hi Paul,

I am happy to inform you that there is straightforward way to achieve your requirement. You can subscribe to the ConnectionManipulationCompleted event and check the e.Shape property. This holds the target shape. Furthermore, in order to cancel the connection all you need to do is to mark the event as handled like this:

private void diagram_ConnectionManipulationCompleted(object sender, ManipulationRoutedEventArgs e)
{
    var targetShape = e.Shape as RadDiagramShape;
    if (targetShape != null && targetShape.Content.Equals("Test Shape 2"))
    {
        e.Handled = true;
    }
}
I hope this will help you. Please do not hesitate to ask if you need any further assistance.

Regards,
Pavel R. Pavlov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Paul
Top achievements
Rank 1
answered on 11 Dec 2013, 11:47 PM
Hi,

Thank you for the information.

The content property is null for me using the example code that you have provided.

So to be clear, what I would like to do if a user drops a  Cross and a Cross 2 from the toolbox and the user tries to connect these two together then I should cancel the connection and information the user that they cannot connect these two types together.

Regards
Paul.
0
Pavel R. Pavlov
Telerik team
answered on 14 Dec 2013, 03:24 PM
Hello Paul,

The earlier provided code serves to illustrate my words. I used the Content property for simplicity. In your particular case, you as a developer will need to evaluate if the user action is valid and if not you just need to mark the event as handled, in order to prevent that action.
Regards,
Pavel R. Pavlov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
Diagram
Asked by
Paul
Top achievements
Rank 1
Answers by
Pavel R. Pavlov
Telerik team
Paul
Top achievements
Rank 1
Share this question
or