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

Drag and Drop with RadDiagramShape.Tag valued

1 Answer 51 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Dario Concilio
Top achievements
Rank 2
Dario Concilio asked on 30 May 2017, 03:51 PM

I'm trying to drag&drop from my radlistbox that has ItemSource with my Collection (by MVVM)

I valued RadDiagramShape.Tag property with my object, I would to send this one also.

But into ItemsChanged event I found Tag = null.

How can I do this?

DragDropManager.AddDragInitializeHandler(MacchineDaCaricareRadListBox, OnDragInitialize);
 
private void OnDragInitialize(object sender, DragInitializeEventArgs args)
{
    args.AllowedEffects = DragDropEffects.All;
 
    //RadDiagramShape draggedShape = (args.OriginalSource as ListBoxItem).Content as RadDiagramShape;
    GruppoPianoDiCarico pallet = (args.OriginalSource as RadListBox).SelectedValue as GruppoPianoDiCarico;
 
    RadDiagramShape macchina = new RadDiagramShape()
    {
        Width = pallet.Lunghezza / SCALE,
        Height = pallet.Larghezza / SCALE,
        Content = $"[{pallet.NumeroRiga}] {pallet.Description.ToUpper()}",
        Tag = pallet
    };
    macchina.Geometry = ShapeFactory.GetShapeGeometry(CommonShapeType.RectangleShape);
    macchina.Background = IMBALLO;
    macchina.Foreground = IMBALLO_TITLE;
    macchina.FontWeight = FontWeights.Bold;
    macchina.Stroke = Brushes.Black;
    macchina.StrokeThickness = 1;
    macchina.StrokeDashArray = new DoubleCollection(new Double[] { 5, 1 });
    macchina.FontSize = 20;
 
    List<RadDiagramShape> shapes = new List<RadDiagramShape>();
    shapes.Add(macchina);
    SerializationInfo serializaedInfo = SerializationService.Default.SerializeItems(shapes);
    args.Data = serializaedInfo;
}

 

private void topRadDiagram_ItemsChanged(object sender, DiagramItemsChangedEventArgs e)
{
    [...]

if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
{
foreach (var item in e.NewItems)
{
var currenItem = (RadDiagramShape)item;

//it founds Tag = null!!!!
if (currenItem.Tag.GetType() == typeof(GruppoPianoDiCarico))
{
var macchina = (GruppoPianoDiCarico)currenItem.Tag;

vm.MacchineDaCaricare.Remove(macchina);
vm.MacchineCaricate.Add(macchina);
}
}
}
}

1 Answer, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 02 Jun 2017, 06:39 AM
Hello Dario,

Tag property is not in the list of properties automatically serialized and deserialized in RadDiagram. Please check the list here. Also, in the following section you will get an idea how to include the Tag serialization in your scenario:

Manual Serialization / Deserialization

Regards,
Petar Mladenov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
Diagram
Asked by
Dario Concilio
Top achievements
Rank 2
Answers by
Petar Mladenov
Telerik team
Share this question
or