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