I can able to reordering row i.e drag and drop from one index position to another index position in NSTableView in mac but I am not able to get any effect while dragging and dropping row. How can I set any styling for feel to rows are reordering. I have using three overriden methods in TableViewDataSource for rows reordering i.e 1.WriteRows 2.ValidateDrop 3.AcceptDrop. Please suggest any idea, Thanks in advance.
Asked
Active
Viewed 188 times
1 Answers
0
You can do a UITableView.MoveRow
in your AcceptDrop
method and extended the duration of the visual move between rows via an NSAnimationContext
:
Note: This does not reorder the data in the datasource, if preserving the user's new data order is required, you will have to manually reorder that data so a UITableView.ReloadData
will show the correct order.
public override bool AcceptDrop(NSTableView tableView, NSDraggingInfo info, nint row, NSTableViewDropOperation dropOperation)
{
var rowData = info.DraggingPasteboard.GetDataForType(typeof(Product).FullName);
if (rowData == null)
return false;
var dataArray = NSKeyedUnarchiver.UnarchiveObject(rowData) as NSIndexSet;
NSAnimationContext.BeginGrouping();
NSAnimationContext.CurrentContext.Duration = 1;
foreach (var originalIndex in dataArray.ToArray())
{
tableView.MoveRow((nint)originalIndex, row);
}
NSAnimationContext.EndGrouping();
return true;
}

SushiHangover
- 73,120
- 10
- 106
- 165