Drag/Drop process: How to set drag tooltip for a Header property when i.e. Grid control is used as a header

3 posts, 0 answers
  1. Marcin
    Marcin avatar
    2 posts
    Member since:
    Nov 2010

    Posted 16 Nov 2010 Link to this post

    Is it possible to change a tooltip of a header property when a header contains i.e. grid control. It is not user friendly when during drag/drop process user see a tooltip that can look like that "Drop In System.Windows.Control.Grid". When a header contains just a text it looks ok but if it contains a control there is such a problem. Some example code to reproduce mentioned problem:
    Grid grid = new Grid();
    var image = new Image(); //Set some picture for example
    var header = new TextBlock { Text = "Header" };
     
    Grid.SetRow(image, 0);
    Grid.SetColumn(image, 0);
    Grid.SetRow(header, 0);
    Grid.SetColumn(header, 1);
     
    grid.Children.Add(image);
    grid.Children.Add(header);
    var item = new RadTreeViewItem { Header = grid };

    radTreeView.Items.Add(item);
  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 18 Nov 2010 Link to this post

    Hi Marcin,

    The TreeViewDragCue control is used to display the DragCue and it can be styled accordingly to your needs. However, your scenario cannot be implemented out-of-the-box since the TreeViewDragCue control is an ItemsControl and you have to modify its ControlTemplate and replace the ItemsPresenter accordingly to your needs.

    Also, there are a couple of points that have to be taken into consideration. Firstly, you have to make sure that the TreeViewDragCue is changed only to the Items that cannot be properly displayed. You can handle the  DragInfo() event and do a sample if statement.

    Secondly, you will have to make sure that the DragToolTipContent of the "Grid-Headered" items is also updated accordingly. Therefore you have to handle the DropInfo() event as well.

    I prepared a sample project for you , illustrating the described approach.

    Still, I was wondering why you need to set the RadTreeViewItem Header to a Grid. If you need to display an Image within each RadTreeViewItem, you can take advantage of the built-in Image functionality of the RadTreeViewItem. You can find more info here. I also demonstrated this approach in the attached example. As you can see, in this case, you don't have to manually configure the TreeViewDragCue.

    I hope this information helps. Please let us know if you need more info.

    Sincerely yours,
    Tina Stancheva
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  3. DevCraft banner
  4. Marcin
    Marcin avatar
    2 posts
    Member since:
    Nov 2010

    Posted 19 Nov 2010 Link to this post

    Thanks a lot for the explanation and the example code. Of course you are right that the built-in Image functionality is sufficient for the purpose of the problem I mentioned. But your answer is a very usefull information anyway. Thanks again.

    Best regards
    Marcin
Back to Top