Monday, April 25, 2011

Draw custom element between listbox items

I want to draw custom elements (like an empty square> between the items of a listbox, to indicate that users can insert/drop items from another listbox between other items.

How can I do this? I have some rather hacky solution for this, but I hope there is an easier way to do this.
One of the ideas is to use different DataTemplates for items for odd and even indexes in the listbox.

From stackoverflow
  • There is a very elegant solution to this that can be seen here.

    (if the link ever goes out of date, as it has once already, a google search on "bea stollnitz drag drop listbox" will probably get you to the right page, if it exists.)

    Loy : Thanx for the fast reply, it could be part of the solution. But: I want to draw the line always, even when i'm not hovering above the insertion-spot. This is key to the app, because it will run on a touch screen, and people's fingers will cause people not see the insertion-adorner. Any ideas?
    Beska : The code can be modified to do that. The key is to just change when the insertion adorner is rendered from "only sometimes" to "always". I expect it would make the code simpler.
    Amit Chintawar : Hi beska, I'm really interested in your solution but the link seems to be not working. Can you post fresh link.
    Beska : @Amit: Ah! Thanks for the heads up. I've updated the content to the new link.

0 comments:

Post a Comment