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

DragDropManager issues dragover issues

1 Answer 97 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Vidyadhar
Top achievements
Rank 1
Vidyadhar asked on 24 Sep 2019, 01:22 PM

 

Hi,

I want to highlight the row on dragover where I am dropping an item from the grid. I have two different gridviews. I drag a row from one grid and drop on to other grid row,

I have written following code for Highlighting a gridviewrow on a Item dragover,

public T4ShipmentSchedulerView(IT4ShipmentSchedulerViewModel viewModel)
{
InitializeComponent();
StyleManager.SetTheme(ShipmentGrid, new OWBTheme());
DataContext = viewModel;
viewModel.GridOperations = new TelerikGridOperations(ShipmentGrid, Constants.T4ShipmentBuilderGridSettings);
//ShipmentGrid.RowLoaded += ShipmentGrid_RowLoaded;
}
private void ShipmentGrid_RowLoaded(object sender, RowLoadedEventArgs e)
{
GridViewRow row = e.Row as GridViewRow;
if (row == null) return;
DragDropManager.RemoveDragEnterHandler(row, OnRowDragOver);
DragDropManager.AddDragEnterHandler(row, OnRowDragOver);
DragDropManager.RemoveDragLeaveHandler(row, OnRowDragLeave);
DragDropManager.AddDragLeaveHandler(row, OnRowDragLeave);
DragDropManager.RemovePreviewDropHandler(row, OnPreviewDropLeave);
DragDropManager.AddPreviewDropHandler(row, OnPreviewDropLeave);
}
private void OnPreviewDropLeave(object sender, DragEventArgs e)
{
OnRowDragLeave(sender, e);

}

private void OnRowDragLeave(object sender, DragEventArgs e)
{
GridViewRow row = sender as GridViewRow;
if (row != null)
{
row.Background = _backGround;
row.Foreground = _foreGround;

}

}
Brush _backGround;
Brush _foreGround ;
private void OnRowDragOver(object sender, DragEventArgs e)
{
GridViewRow row = sender as GridViewRow;
if (row != null)
{
_backGround = row.Background;
_foreGround = row.Foreground;
row.Background = new SolidColorBrush(Colors.Gold);
row.Foreground = new SolidColorBrush(Colors.Black);
}

        }

 

It highlights the row on drag over but it messes with other trigger styles and they stop working. Do we have more proper soln on this.

 

Regards,

Vidyadhar

1 Answer, 1 is accepted

Sort by
0
Vladimir Stoyanov
Telerik team
answered on 27 Sep 2019, 01:18 PM

Hello Vidyadhar,

Thank you for the shared code. 

I checked out the described behavior, however there isn't a convenient way to highlight a row when dragging over it. Working directly with the GridViewRow elements by setting their Background is also not recommended.

That said, I can suggest checking out the following article in our documentation: Drag and Drop within RadGridView and the related SDK example: DragDropWithLines, which demonstrate how to give visual feedback while dragging. 

Hope this helps.

Regards,
Vladimir Stoyanov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Vidyadhar
Top achievements
Rank 1
Answers by
Vladimir Stoyanov
Telerik team
Share this question
or