DragVisual "effect" icon?

6 posts, 0 answers
  1. Steve
    Steve avatar
    46 posts
    Member since:
    May 2014

    Posted 16 Jan Link to this post

    From the drag drop examples on the site, the dragging and dropping within and between grid views is more or less working how we want. But I would like to change the icon in the visual associated with the "effect" and I can't seem to figure out how and where to do it. We have a content template but that only affects the rest of the visual and not the "effect" portion of it.

    I tried inheriting from the DragVisual but there are so many overridable things within I can't tell what is needed to be done. One thing however that was particularly interesting, is that when I inherit from the DragVisual but do not override anything within, the "move" icon is gray instead of blue.

    I am trying to achieve displaying a delete icon if the user drags an item outside of the grid to indicate that the item will be removed rather than the "no" icon which implies that the action will have no result. Please advise if there is a simpler way to do this.

  2. Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    503 posts

    Posted 19 Jan Link to this post

    Hi Steve,

    I am not sure which demos you are referring to, but I guess you have checked the DragDrop - Tree To Grid one from our WPF Demos Application.

    It would not be possible to modify the icons while using the DragVisual element. However, you can assign a custom control or whatever element you desire to the e.DragVisual argument in the OnDragInitialize event:

    private void OnDragInitialize(object sender, DragInitializeEventArgs e)
            {
                . . .
                //set the DragVisual to whatever element you desire
                e.DragVisual = new TextBlock() { Text = "Some Text" };
                . . .
            }

    Would this work for you?

    Regards,
    Stefan Nenchev
    Telerik by Progress
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
  3. Darren
    Darren avatar
    7 posts
    Member since:
    Mar 2016

    Posted 21 Feb in reply to Stefan Nenchev Link to this post

    Is it possible to hide that feedback icon at all and only display the content we add to DragVisual?
  4. Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    503 posts

    Posted 22 Feb Link to this post

    Hello Darren,

    In order to avoid providing you with misleading information, can you confirm which exactly icon you are referring to? Please point out the example that you are using and the action in which the icon appears so we can advise you.

    Regards,
    Stefan Nenchev
    Telerik by Progress
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
  5. Darren
    Darren avatar
    7 posts
    Member since:
    Mar 2016

    Posted 22 Feb in reply to Stefan Nenchev Link to this post

     

     

     

    Hi,

    I've attached an image pointing out the icon and also pasted our code below.  

    Darren

     

    private void OnDragInitialize(object sender, DragInitializeEventArgs dragInitializeEventArgs)
    {
        if (_currentFixtureViewModel == null) return;
     
        DropIndicationDetails details = new DropIndicationDetails();
        List<ProductSimpleVM> productsVM = new List<ProductSimpleVM>();
     
        var selectedCells = (sender as RadGridView).SelectedCells;
        if (!selectedCells.Any()) return;
         
        foreach (var cell in selectedCells)
        {
                var prodVM = cell.Item as ProductSimpleVM;
                if (prodVM == null) continue;
                if (productsVM.FirstOrDefault(alreadyAddedVM => alreadyAddedVM.EAN == prodVM.EAN) != null) continue;
     
                ((ProductSimpleVM)cell.Item).Scaling = _currentFixtureViewModel.ScalingParams;
                productsVM.Add((ProductSimpleVM)cell.Item);
        }
        if (selectedCells.Count == 0) return;
            details.CurrentDraggedItems = productsVM;
     
        IDragPayload dragPayload = DragDropPayloadManager.GeneratePayload(null);
     
        dragPayload.SetData(Constants.WarehouseProductDragFormatName, productsVM);
        dragPayload.SetData("DropDetails", details);
     
        dragInitializeEventArgs.Data =  dragPayload;
     
        dragInitializeEventArgs.DragVisual = new DragVisual()
        {
            Content = details,
            ContentTemplate = this.AssociatedObject.Resources["DraggedItemTemplate"] as DataTemplate
        };
        var productHeightOffset = selectedCells.Max(p => ((ProductSimpleVM)p.Item).Height) * _currentFixtureViewModel.ScalingParams.Scale;
     
        Point dragVisualOffset = new Point(dragInitializeEventArgs.RelativeStartPoint.X, dragInitializeEventArgs.RelativeStartPoint.Y - productHeightOffset);
        dragInitializeEventArgs.DragVisualOffset = dragVisualOffset;
        dragInitializeEventArgs.AllowedEffects = DragDropEffects.All;
    }
  6. Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    503 posts

    Posted 24 Feb Link to this post

    Hello Darren,

    As advised in my original answer, you can set a control of your choice to the DragVisual parameter in the OnDragInitialize event. Please check the Set Drag Visual article from our documentation page. 

    Regards,
    Stefan Nenchev
    Telerik by Progress
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top