Drag RadTreeViewItem without make it selected

2 posts, 1 answers
  1. Diego
    Diego avatar
    11 posts
    Member since:
    May 2009

    Posted 14 Jan 2010 Link to this post

    Hi to all,
    i just would like to drag a RadTreeViewItem on a different component without make it selected.
    Right now i have tried different ways without success...

    I have implemented the PreviewMouseLeftButtonDown handler when the item is prepared, so when the user just press down the mouse i store the treeviewitem and put the e.Handled = true just to leave it unselected. When the event PreviewMouseLeftButtonUp is fired i will get the stored element and make it selected (so no drag operation...just a normal click on the element).

    The big problem is that the
    e.PreparedItem.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(PreparedItem_PreviewMouseLeftButtonDown);

    is sent different times..the first time the source is the "root" element of the RadTreeView the second time the first child of the root element and so on. I think it is not correct to fire so many events if i mouse down only on one RadTreeViewItem...i aspect to have directly on the first event the right treeviewitem on the source!

    Do you have any idea how to implement this scenario?

    Really Thanks.
    Diego Bonura




  2. Answer
    Miroslav
    Admin
    Miroslav avatar
    922 posts

    Posted 20 Jan 2010 Link to this post

    Hi Diego,

    By default the dragged items are the selected items of the TreeView.

    This can be changed by overriding the DragQuery and specifying that the dragged item will be the one that the mouse is mouse dragging.

    I have attached a project demonstrates this.

    Best wishes,
    Miroslav
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top