Drag and Drop Reorder controls within Grid panel WPF

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>

Answers


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..


Need Your Help

Nested resources conflict in Rails routes

ruby-on-rails ruby-on-rails-3

With the following routes I am running into a conflict issue. It seems that both cannot exist together. How can I specify both without conflict? Thanks.

Segmentation fault in hash table

c++ segmentation-fault hashtable

I don't understand why a segmentation fault is occurring in my program. Can someone explain the problem?