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

Helper arrows when dragging to reorder columns in GridView

5 Answers 78 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 07 Aug 2011, 12:17 AM
Hi,

I noticed you have functionality to give 'helper arrows' to the user when dragging to reorder columns for ASP.NET (an up and down arrow to point to where the column will go), shown here:
http://demos.telerik.com/aspnet-ajax/grid/examples/client/resizing/defaultcs.aspx

Is this type of behavior possible with the WPF version of the RadGridView control?

Thanks in advance,
Mark

5 Answers, 1 is accepted

Sort by
0
Accepted
Ivan Ivanov
Telerik team
answered on 10 Aug 2011, 01:18 PM
Hello Mark,

I have prepared a simple example projects that indicates drop position by changing header cell's border thickness. Would you please, confirm whether such an approach meets your requirements or we should think of an alternative solution? However, since RadGridView has never been meant to have such an indicator arrow in its template, such a task may lead to the retemplation of several of its parts. 

All the best,
Ivan Ivanov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
0
Mark
Top achievements
Rank 1
answered on 10 Aug 2011, 10:42 PM
That might work okay (your sample works fine), but for some reason my RadGridView will not fire the DragEnter, DragLeave or Drop events.  They all get registered (i.e. the below BookGrid_Loaded is fired and it goes through the loop), but they do not ever get handled when I reoder the columns.

private void BookGrid_Loaded(object sender, RoutedEventArgs e)
{
    var rightThumbs = (sender as RadGridView).ChildrenOfType<GridViewHeaderCell>().SelectMany(hc => hc.ChildrenOfType<Thumb>()).Where(th => th.Name == "PART_RightHeaderGripper");
    foreach (Thumb th in rightThumbs)
    {
        th.DragEnter += new DragEventHandler(th_DragEnter);
        th.DragLeave += new DragEventHandler(th_DragLeave);
        th.Drop += new DragEventHandler(th_Drop);
    }
}
 
void th_Drop(object sender, DragEventArgs e)
{
    (sender as Thumb).ParentOfType<GridViewHeaderCell>().ChildrenOfType<Border>().Where(b => b.Name == "GridViewHeaderCell").First().BorderThickness = new Thickness();
}
 
void th_DragLeave(object sender, DragEventArgs e)
{
    (sender as Thumb).ParentOfType<GridViewHeaderCell>().ChildrenOfType<Border>().Where(b => b.Name == "GridViewHeaderCell").First().BorderThickness = new Thickness();
}
 
void th_DragEnter(object sender, DragEventArgs e)
{
    (sender as Thumb).ParentOfType<GridViewHeaderCell>().ChildrenOfType<Border>().Where(b => b.Name == "GridViewHeaderCell").First().BorderThickness = new Thickness(0, 0, 4, 0);
    (sender as Thumb).ParentOfType<GridViewHeaderCell>().ChildrenOfType<Border>().Where(b => b.Name == "GridViewHeaderCell").First().BorderBrush = new SolidColorBrush(Colors.Black);
}


Can you think of a reason why this would happen?

Let me know if you need any more information or code snippets.

Thanks,
Mark
0
Ivan Ivanov
Telerik team
answered on 11 Aug 2011, 07:29 AM
Hello Mark,

I do not see anything different from my code in the snipped you have applied. Unfortunately it would be difficult for me to guess the issue's source having so limited information on your scenario. Would you please open a support ticket, sending us a simple demo project that reproduces this problem, so that I could debug it on my side. Please, excuse us for the inconvenience.

Best wishes,
Ivan Ivanov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
0
Mark
Top achievements
Rank 1
answered on 12 Aug 2011, 04:20 PM
I figured out my issue.  I was loading my IsolatedStorageFile (with GridView settings in it) on Window_Loaded, not after Grid_Loaded.  Once I moved that to after applying the events, it worked great!

Thanks!
0
Mark
Top achievements
Rank 1
answered on 13 Aug 2011, 06:34 PM
Just as an FYI, I made a slight modification to your attached code, which allows the styles to go back to their original state (since your example was changing the style from the out of box ones):
private Thickness _ThumbThickness;
private Brush _ThumbBrush;
 
void th_Drop(object sender, DragEventArgs e)
{
    (sender as Thumb).ParentOfType<GridViewHeaderCell>().ChildrenOfType<Border>().Where(b => b.Name == "GridViewHeaderCell").First().BorderThickness = _ThumbThickness;
    (sender as Thumb).ParentOfType<GridViewHeaderCell>().ChildrenOfType<Border>().Where(b => b.Name == "GridViewHeaderCell").First().BorderBrush = _ThumbBrush;
}
 
void th_DragLeave(object sender, DragEventArgs e)
{
    (sender as Thumb).ParentOfType<GridViewHeaderCell>().ChildrenOfType<Border>().Where(b => b.Name == "GridViewHeaderCell").First().BorderThickness = _ThumbThickness;
    (sender as Thumb).ParentOfType<GridViewHeaderCell>().ChildrenOfType<Border>().Where(b => b.Name == "GridViewHeaderCell").First().BorderBrush = _ThumbBrush;
}
 
 
void th_DragEnter(object sender, DragEventArgs e)
{
    _ThumbThickness = (sender as Thumb).ParentOfType<GridViewHeaderCell>().ChildrenOfType<Border>().Where(b => b.Name == "GridViewHeaderCell").First().BorderThickness;
    _ThumbBrush = (sender as Thumb).ParentOfType<GridViewHeaderCell>().ChildrenOfType<Border>().Where(b => b.Name == "GridViewHeaderCell").First().BorderBrush;
    (sender as Thumb).ParentOfType<GridViewHeaderCell>().ChildrenOfType<Border>().Where(b => b.Name == "GridViewHeaderCell").First().BorderThickness = new Thickness(0, 0, 4, 0);
    (sender as Thumb).ParentOfType<GridViewHeaderCell>().ChildrenOfType<Border>().Where(b => b.Name == "GridViewHeaderCell").First().BorderBrush = new SolidColorBrush(Colors.Black);
}

Cheers!
Tags
GridView
Asked by
Mark
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Mark
Top achievements
Rank 1
Share this question
or