Accessing bound object on drop into tileview

2 posts, 0 answers
  1. Nabil Shuhaiber
    Nabil Shuhaiber avatar
    14 posts
    Member since:
    Sep 2009

    Posted 16 Aug 2010 Link to this post

    I have a tileview bound to an observablecollection A. I have implemented drag drop from a listbox bound to another observablecollection B. When I drag and drop from B to A I want to be able to access the item in the panel at the position I am dropping into if one exists. The reason is I may need to swap that item with the new one I am dropping in and there are also cases where I want to validate whether the user is allowed to drop the item into that position. Is this possible?

  2. Miroslav
    Miroslav avatar
    922 posts

    Posted 17 Aug 2010 Link to this post

    Hi Nabil Shuhaiber,

    It should be possible to traverse the VisualTree and access the objects in it. Normally you can avoid doing this by using routed events.

    In your case if you are registering for the DragDrop (or other) events, you can register on any of the parents of the ListBox, e.g. the TileView itself. Then you can distinguish the different event sources by using the e.Source, you sign up for the event like so:

    tileView.AddHandler(RadDragAndDropManager.DragQyeryEvent, new EventHandler<...>(...));

    Another option is to add a global handler that will be called whenever a routed even passes though an object of this type:

    EventManager.RegisterClassHandler(typeof(ListBox), RadDragAndDropManager.DQEvent, new EventHandler<...>(...));

    This can be registered in a static constructor and will be called every time the event is routed though a ListBox.

    Kind regards,
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft R3 2016 release webinar banner
Back to Top