This is a migrated thread and some comments may be shown as answers.

Getting gridview row of dragged over item

3 Answers 257 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Randy Hompesch
Top achievements
Rank 1
Randy Hompesch asked on 24 Nov 2017, 12:20 PM

Hi,

In the GridViewDragDropBehavior in the OnDragOver event handler, there does not seem to be a way to detect the dragged over row/item. I am trying highlight the dragged over row differently depending on the content of the dragged over row. So, for example, if row 1 cell 1 contains the words "Not on me" I would highlight the row with a red backcolor until they moved off of it and disallow drop. In the examples that I've seen they always show the CurrentDraggedOverItem to be the this.AssociatedObject, which is always the gridview itself. I want the specific row with that is being dragged over. Can I get there from here?

Thanks .... Ed

 

private void OnDragOver(object sender, Telerik.Windows.DragDrop.DragEventArgs e)
{
 
    var data = e.Data as DataObject;
    if (data != null && data.ContainsFileDropList())
    {
        return;
    }
 
    var draggedItem = DragDropPayloadManager.GetDataFromObject(e.Data, "DraggedData");
    var itemsType = (this.AssociatedObject.ItemsSource as IList).AsQueryable().ElementType;
 
 
    if (draggedItem.GetType() != itemsType)
    {
        e.Effects = DragDropEffects.None;
    }
 
    var dropDetails = DragDropPayloadManager.GetDataFromObject(e.Data, "DropDetails") as DropIndicationDetails;
    dropDetails.CurrentDraggedOverItem = this.AssociatedObject;
    dropDetails.CurrentDropPosition = Telerik.Windows.Controls.DropPosition.Inside;
 
    e.Handled = true;
}

3 Answers, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 29 Nov 2017, 10:43 AM
Hello Randy Hompesch,

To change the color of the current drag over row you can create a custom property in your model and bind in XAML to the Background property of the . Then in DragOver event, you can check if the current row contains a "Not on me" and change the color property. To change it back you can subscribe to the DragLeave event. 

I have modified the DragDropWithLines SDK example in our GitHub repository to demonstrate this approach. Hope this information is helpful.

Regards,
Dinko
Progress Telerik
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 you to write beautiful native mobile apps using a single shared C# codebase.
0
Randy Hompesch
Top achievements
Rank 1
answered on 06 Dec 2017, 11:22 AM

Sorry for not getting back to you sooner.

I ran the attached code and nothing appears in the grid.

What am I missing?

Thanks ... Ed

 

0
Dinko | Tech Support Engineer
Telerik team
answered on 07 Dec 2017, 02:18 PM
Hello Randy Hompesch,

You can double check if you have referenced NoXAML binaries. When you are using  binaries you need to merged all required dictionaries for the controls which you are using. You can read more about this in the Styling the Controls help article in our documentation.

Regards,
Dinko
Progress Telerik
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 you to write beautiful native mobile apps using a single shared C# codebase.
Tags
GridView
Asked by
Randy Hompesch
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Randy Hompesch
Top achievements
Rank 1
Share this question
or