Demo: ListBox: AddTo

Nov 3, 2011 at 1:00 AM


I am looking at one of your demos  called ListBox: addTo --- Drgging and droping to a List box. I am reletively new to this project. Would you please help me with the followings:

1. Suppose I have two or more list boxes instead of one ( demo has one list box). When I drop the elements (Empty, half, full), how can I find the dropped listbox's info so that I can add that element to appropriate ListContent observation collection. In current demo, you are always adding to lstItems.add :

In my case it will be 2 or more ListBoxes and I want to add to  appropriate associated ListBox.

 private void DropTarget_DragSourceDropped(object sender, SL_Drag_Drop_BaseClasses.DropEventArgs args)
        if (args.DragSource.Tag.ToString() == "FullBattery")
              lstItems.Add(new ListContent() { ItemText = "Full"        (Here i want to add to either listBox1.add or listBox2.add or ListBox3.add)
               , ImageSrc = new BitmapImage(new Uri("Images/battery_full.png", UriKind.RelativeOrAbsolute))
            } (Basically want to know which ListBox "FullBattery" Dropped to)


2. I am not able to bind the listBox in constructor as in other examples as follow;

      public sucDragDropListBox()


            leftList.ItemsSource = leftItems;  ( Is this possible) Current demo binds in ItemList_Loaded)

             rightList.ItemsSource = rightItems;

current demo binds in ItemList_Loaded event:

 private void itemsList_Loaded(object sender, RoutedEventArgs e)
            lstbxItems = (ListBox)sender;
            lstItems = new ObservableCollection<ListContent>();
            lstbxItems.ItemsSource = lstItems;


Thanks & regards,