views:

1422

answers:

3

I am trying to give a ListBox drag and drop ordering functionality and I have hit a wall. I got it to work when I specify the list box items in xaml but it does not work when I bind to a list it no longer works because the items are no longer of a listboxitem type.

I found this code http://blog.dobaginski.com/josh/?p=52 that allows me to get the underlying ListBoxItem but I can't get the mouse move event to fire.

I have went through other tutorials but have not been able to find one that deals with a ListBox. Has anyone done this with a ListBox.

The events I am using are SelectedChange, MouseMove, and LeftMouseButtonUp (I think that name is right). I am not using LeftMouseButtonDown because I couldn't get it to fire.

+1  A: 

As far as i know you cannot get at the listbox item container when using data binding. YOu could in Beta 1.

You also cannot set a mouse event handler in the style, you must use a data template, just so you know.

You will likely have to use the mouse move event from a parent element, probably the UserControl or main layout control that hosts the listbox.

State changes and animations need to be in the style though so... you still cant get at the listbox item, just the element inside it in the data template.

Oh and if doing drag and drop HitTest is now protected so that will make the Drop harder.

Brian Leahy
+1  A: 

since today you can download the final 2.0 version of Silverlight with some add ons, check the Scott's web log

balexandre
+1  A: 

I've been trying to do the same thing in WPF, but have only found many buggy implementations.

One person has guided me towards the blog of Beatriz Costa, and from what I remember she's one of those rare geniouses, so I suggest you read that as well... I know I will

Blog of Beatriz Costa

TimothyP