16 Answers, 1 is accepted
0
Francois Vanderseypen
Top achievements
Rank 2
answered on 04 May 2012, 07:25 AM
If you look closely at and mimic the code from the samples you should be fine. On a more technical level, the RadDiagram control doesn't use the standard drag-drop mechanism but relies on the Telerik DragDropManager internally. Have a look at the docs of this control, it basically amounts to
DragDropManager.AddDropHandler(YourRadDiagramControl, YourOnDropHandler);
Are you trying to reuse the shapes toolbox or you want to implement a custom drop mechanism?
Hope this helps, Fr.
0
Ambit
Top achievements
Rank 1
answered on 04 May 2012, 07:48 AM
Thanks for Reply,
I have to use dropped shape for creating connection with another shape.
Someone has already discuss about Creating connection on drop on this forum
http://www.telerik.com/community/forums/silverlight/diagram/drag-the-shape-create-connection-between-shapes.aspx
Something like this, I am also trying.
Thanks
DragDropManager
works for drop event but I am not getting dropped shape in this event. DragDropManager.AddDropHandler(this.diagram, diagram_Drop);
private void diagram_Drop(object sender, Telerik.Windows.DragDrop.DragEventArgs e)
{
}
I have to use dropped shape for creating connection with another shape.
Someone has already discuss about Creating connection on drop on this forum
http://www.telerik.com/community/forums/silverlight/diagram/drag-the-shape-create-connection-between-shapes.aspx
Something like this, I am also trying.
Thanks
0
Francois Vanderseypen
Top achievements
Rank 2
answered on 04 May 2012, 11:45 AM
Assuming your XAML looks somewhat like this:
(but any type of visual can be used to drop content onto the surface).
You can access the data and the position on the surface as follows:
The precise logic depends on the actual application you aim for and the functional behavior you are looking for, of course.
Hope this helps, Fr.
<
Grid
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
Height
=
"*"
/>
</
Grid.RowDefinitions
>
<
Rectangle
x:Name
=
"rec"
Fill
=
"Orange"
Width
=
"50"
Height
=
"30"
/>
<
telerik:RadDiagram
x:Name
=
"diagram"
Grid.Row
=
"1"
/>
</
Grid
>
(but any type of visual can be used to drop content onto the surface).
You can access the data and the position on the surface as follows:
public
MainWindow()
{
InitializeComponent();
rec.SetValue(DragDropManager.AllowDragProperty,
true
);
DragDropManager.AddDragInitializeHandler(
this
,
this
.OnDragInitialized);
DragDropManager.AddDropHandler(
this
, OnDropItem);
diagram.AllowDrop =
true
;
}
private
void
OnDragInitialized(
object
sender, DragInitializeEventArgs e)
{
var shape =
new
RadDiagramShape { Geometry = ShapeFactory.GetShapeGeometry(CommonShapeType.Star5Shape), Width = 50, Height = 50 };
e.DragVisualOffset =
new
Point(e.RelativeStartPoint.X - 25, e.RelativeStartPoint.Y - 25);
var dragDropInfo = shape;
e.Data = dragDropInfo;
e.AllowedEffects=DragDropEffects.All;
e.Handled =
true
;
}
private
void
OnDropItem(
object
sender, DragEventArgs e)
{
e.Handled =
true
;
var dataObject = e.Data
as
DataObject;
var formats = dataObject.GetFormats().ToList();
if
(formats.Contains(
typeof
(RadDiagramShape).FullName) )
{
var shape =
new
RadDiagramShape { Geometry = ShapeFactory.GetShapeGeometry(CommonShapeType.Star5Shape), Width = 50, Height = 50 };
var p = e.GetPosition(diagram);
diagram.AddShape(shape, position: diagram.GetTransformedPoint(p));
}
}
The precise logic depends on the actual application you aim for and the functional behavior you are looking for, of course.
Hope this helps, Fr.
0
Shrikant
Top achievements
Rank 1
answered on 04 May 2012, 12:49 PM
Hi,
I am getting error on
at line
var formats = dataObject.GetFormats().ToList(); --> (Object reference not set to an instance of an object.)
And for your information I have DesignToolBox Sample code on my project.
& I am dropping shapes from ToolBox.
Please let me know If I am doing something wrong.
Thanks
I am getting error on
OnDropItem
eventat line
var formats = dataObject.GetFormats().ToList(); --> (Object reference not set to an instance of an object.)
And for your information I have DesignToolBox Sample code on my project.
& I am dropping shapes from ToolBox.
Please let me know If I am doing something wrong.
Thanks
0
0
Hello Ambit and Shrikant,
Petar Mladenov
the Telerik team
You can find attached the code sample from Francois. Please let us know if you need further assistance.
Regards,Petar Mladenov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
0
Hello Ambit,
Petar Mladenov
the Telerik team
I am attaching the full DesignToolBox Demo code.
Kind regards,Petar Mladenov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Yogendra
Top achievements
Rank 1
answered on 06 Sep 2013, 12:16 PM
Hi Petar,
Can you suggest me , How can fired Drag and drop event of diagram in silverlight?
Thanks
Regrads
Yogendra
Can you suggest me , How can fired Drag and drop event of diagram in silverlight?
Thanks
Regrads
Yogendra
0
Hello Yogendra,
You can use the OnDrop of the Diagram or DragDropmanager.DragInitialize. However, if this question is related to ToolBox issues, you can check DrawingDemo which demonstrates the Events DiagramSerializationService.ItemSerializing and Diagram.ShapeDeserialized which fires when shape is dragged and then when it is dropped in diagram. You can use these events to save custom properties, like the Geometry property in the Drawing sample.
Regards,
Petar Mladenov
Telerik
You can use the OnDrop of the Diagram or DragDropmanager.DragInitialize. However, if this question is related to ToolBox issues, you can check DrawingDemo which demonstrates the Events DiagramSerializationService.ItemSerializing and Diagram.ShapeDeserialized which fires when shape is dragged and then when it is dropped in diagram. You can use these events to save custom properties, like the Geometry property in the Drawing sample.
Regards,
Petar Mladenov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
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 >>
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
Ajay
Top achievements
Rank 1
answered on 07 Jan 2014, 11:08 AM
Hi ,
I am using Rad diagram but while using diagrams while selecting or deselecting a diagram sometimes selection hangs on one only.
Please let me me know how I can overcome this.
Regards
Ajay Negi
I am using Rad diagram but while using diagrams while selecting or deselecting a diagram sometimes selection hangs on one only.
Please let me me know how I can overcome this.
Regards
Ajay Negi
0
Hi Ajay,
Could you please elaborate more on your particular scenario ? What type of selection do you perform - programmatically , with mouse click , or with mouse rectangle selection ? What is the number of shapes / connections that you select ? Is it possible for you to send us a captured video of this issue which can help us better investigate it ? This will be highly appreciated and we will be better able to advice you.
Thank you in advance for your cooperation.
Regards,
Petar Mladenov
Telerik
Could you please elaborate more on your particular scenario ? What type of selection do you perform - programmatically , with mouse click , or with mouse rectangle selection ? What is the number of shapes / connections that you select ? Is it possible for you to send us a captured video of this issue which can help us better investigate it ? This will be highly appreciated and we will be better able to advice you.
Thank you in advance for your cooperation.
Regards,
Petar Mladenov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
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 >>
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
Ajay
Top achievements
Rank 1
answered on 10 Jan 2014, 10:41 AM
With the selection of rectangle click some time the selection sticks on one and we are not able select any other. PFA screenshot
0
Hello Ajay,
We tried to reproduce such issue on our side but we did not succeed. That is why we want to ask you if you are able to reproduce it in a sample project, for example in our Diagrams First Look Demo (SL or WPF). We want to investigate this further because performance issues are usually of high importance
but we will definitely need a starting point to look at. On the other hand, can you please also confirm that you are using our latest Release - Q3 2013 or Q3 2013 SP ?
Regards,
Petar Mladenov
Telerik
We tried to reproduce such issue on our side but we did not succeed. That is why we want to ask you if you are able to reproduce it in a sample project, for example in our Diagrams First Look Demo (SL or WPF). We want to investigate this further because performance issues are usually of high importance
but we will definitely need a starting point to look at. On the other hand, can you please also confirm that you are using our latest Release - Q3 2013 or Q3 2013 SP ?
Regards,
Petar Mladenov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
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 >>
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
Ajay
Top achievements
Rank 1
answered on 24 Mar 2014, 11:21 AM
var gh = diagram.Shapes;
foreach (RadDiagramShape row in gh)
{ row.ShapeDoubleClick+= ShapeDoubleClicked}
how to do this.
I want to double click each shape of RadDiagramShape through c#
to call function
diagram_ShapeDoubleClicked(object sender, ShapeRoutedEventArgs e)
0
Hi Ajay,
Could you please elaborate a bit more on your scenario ? This way we would be better able to advice you.
Basically, the RadDiagram.ShapeDoubleClicked event which will fire on every double click performed on RadDiagramShapes.
Regards,
Petar Mladenov
Telerik
Could you please elaborate a bit more on your scenario ? This way we would be better able to advice you.
Basically, the RadDiagram.ShapeDoubleClicked event which will fire on every double click performed on RadDiagramShapes.
Regards,
Petar Mladenov
Telerik
Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.