I almost have this working and just need some guidance on whether I'm going about this correctly and more importantly how to fix the tiny issue I am having.
I have uploaded a small sample project with the problem mentioned below.
I want to be able to drag multiple grid rows from the XamGrid to a XamTree. I don't physically need anything to move or change, I just need it to appear to the user they are dragging something to a specific XamTreeitem.
By crawling the forums I found a couple different approaches to this. Non seemed to be a perfect fit or to work completely but I was able to splice together something that almost works.
Approach
I loaded the tree nodes dynamically in code-behind and call SetDropTarget to specify which nodes are DropTargets. Working perfectly.
I could not figure out how to get XamGrid row's to be Drag Source objects. I posted elsewhere about this but know one has replied.
I found an example where they provided a custom DragTemplate at the XamGrid level. I put a TextBlock in the DataTemplate with Text="" so I basically get what I want. Just the default drag cursor and not the whole entire grid moving. This seems to work and I have only one issue with the XamGrid.
After the drag is finished, if I move the mouse back to the XamGrid, it starts selected all rows until I refocus or re-click the grid. Its like something gets messed up with its Visual State.
Any help would be greatly appreciated.
Hello,
It's because of a bug of DragDrop. A new service release is expected in next few days where this issue is fixed.
Best regards.Plamen.
Great! I eagerly await the service release.
I have 1 more problem to figure out. Grid rows can only be dragged to certain folders. I was originally thinking that I could set DropChannel and DragChannel but since I cannot figure out how to set the drag source on a row by row basis this doesn't appear to be an option.
How would your recommend that during that dragover I calculate that the grid row (or rows) is actually allowed to be dropped on this particular XamTreeItem and if its not, change curror back to not allowed?
I think this is my last hurdle.
Thanks in advance!
Ken
Hi Ken,
Do you want to be able to drag from anywhere on a Row, and start dragging it? Or are you looking for more of a Drag handle, like having an extra column which a user can click and drag from?
-SteveZ
Hi Steve,
I was hoping for the ability to drag from anywhere on the row.
Just wish I could set a Row as a DragSource dynamically in code then I could customize the DragChannel.
Thanks in advance for looking into this.
Hey Ken,
If you want to be able to drag from anywhere on the row, then the best way to do this, would be to re-template the the CellControl of the grid, and stick your DragSource attached property right in there.
Then set that newly created style to the CellStyle property off of the Grid.
Here is a link on how to use Blend to restyle the CellControl:
http://help.infragistics.com/NetAdvantage/Silverlight/2010.2/CLR4.0/?page=SL_DesignersGuide_Editing_Style_Properties_Using_Expression_Blend.html
If you don't have blend, then you can go to your installation and pull the grid's generic.xaml and find the CellControl yourself:
http://help.infragistics.com/NetAdvantage/Silverlight/2010.2/CLR4.0/?page=SL_DesignersGuide_Location_of_Generic_xaml_File.html
Another option, is to use the CellControlAttached event, although i don't like this approach as much.
In there, you can check to see if you've already set a DragSource on a Row's Control property, which is a CellsPanel. If you haven't set it as a DragSource, you can then set it.
Hope this helps.
Steve,
First, thanks for the quick reply.
I actually already tried the first method you suggested by taking the default style for the CellControl from the XamGrid.xaml file in the Default Styles folder. It was working at the cell level (meaning it showed the cell dragging). I opted for the method I did in the demo application because it let me control how the drag worked. And I liked it except I have the annoying requirement that each grid row needs to drag to potentially different XamTreeItems. Meaning it can only be dragged to 2 of the 10 nodes, etc. The only way to accomplish this I believe (since I don't see any events on the DropTarget (why?)) is to set the Drag and Drop Channels. Which is why I need to do it at the row level. Your CellControlAttached event actually did help as I could do this
DragSource source = DragDropManager.GetDragSource(e.Cell.Row.Control); if (source == null){ source = new DragSource { IsDraggable = true, DataObject = e.Cell.Row, DragChannels = new ObservableCollection<string>() { "test" } }; DragDropManager.SetDragSource(e.Cell.Row.Control, source);}But there is 1 thing I don't like about this. It drags the whole entire rowvisually when all I really want is the cursor to change. Is there a way I couldset the drag template in code? Or in xaml, while still attaching eachrow.Control to the DragDropManager?Thanks in advance.
Hi,
The 10.2 SR was just released:
http://es.infragistics.com/dotnet/netadvantage/silverlight/line-of-business.aspx#Downloads
For some reason the link Plamen sent you wasn't updated to contain the 10.2 SR.
Bummer, I don't see a service release for 10.2 Line of Business (which has the same problem). I only see a 10.1 service release. Was hoping to bite the bullet and just upgrade to 10.2 to get the name spaces in order.
Thanks for all your help guys.
Plamen,
Thanks, great link.
Hello Ken,
Here you can find information about service releases.
Any idea when that service release is coming out?
Is there a forum or place on your site I can read about service releases (dates and info on what was fixed etc).