4

I am almost new to WPF.

I have a Grid panel shown in the picture. I want to add the drag & drop functionality so that a user can reorder the buttons within the cells of the grid (The user should be able to put the buttons into each cell she wants.)

<Grid >
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="137*"/>
        <ColumnDefinition Width="139*"/>
        <ColumnDefinition Width="112*"/>
        <ColumnDefinition Width="129*"/>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="58*"/>
        <RowDefinition Height="59*"/>
        <RowDefinition Height="60*"/>
        <RowDefinition Height="55*"/>
        <RowDefinition Height="88*"/>
    </Grid.RowDefinitions>

    <Button Content="Drag" Grid.Column="0" Grid.Row="0"></Button>
    <Button Content="Drag" Grid.Column="2" Grid.Row="0"></Button>
    <Button Content="Drag" Grid.Column="0" Grid.Row="3"></Button>
</Grid>

enter image description here

Mehrdad Kamelzadeh
  • 1,764
  • 2
  • 21
  • 39
  • 7
    FYI, SO is for asking specific programming questions, not vague "write my entire program for me" requests. If you have a specific problem, (getting a drag image, detecting which grid cell the item is dropped on, etc.) ask that instead. – Ming Slogar Jan 04 '14 at 21:14
  • 1
    Did you find a answer to this question? – Xavier Huppé Mar 11 '14 at 13:53
  • I Want To Do Almost The Same, Did You Found Any Answer To Share With Us? – Ivan Verges Jun 02 '14 at 18:33
  • 2
    See here: http://blog.jerrynixon.com/2013/06/walkthrough-reordering-items-in.html or here: http://www.codeproject.com/Articles/536519/Extending-GridView-with-Drag-and-Drop-for-Grouping – peter Oct 06 '15 at 12:07

1 Answers1

1

If you are looking for a reorderable GridView control in WPF, you will be disappointed. WPF does not have such a control; it does not even have a GridView. A possible solution would be to upgrade to a XAML based (Universal) app that allows you achieve your goal with ease, as demonstrated by the links in the comments, e.g. the Jerry Nixon example.

If you are not willing to roll your own and cannot ditch WPF your best bet is buy a UI component that allows you to do just that. There is Telerik UI for WPF, Infragistics, DevExpress, and others..

wp78de
  • 18,207
  • 7
  • 43
  • 71