Is it possible you guys can post some sample code, that shows drag and drop from XamDataGrid's Field Chooser to the ColumnsFieldDropAreaControl. We have a XamDataGrid and XamPivotGrid in the same screen, and I want to be able to drag columns from XamDataGrid's field chooser to the ColumnsFieldDropAreaControl/RowFieldsDropAreaControl.
Hi Anand,
This might be tricky since the field chooser on the XamDataGrid and the ColumnsFieldDropAreaControl in the pivot grid have their own drag drop handling. I'm putting together a sample to see what can be done. I will get back to you after the investigation.
This was a bit simpler than I initially thought. As I said previously, the XamDataGrid implements it's own version of drag/drop and currently it is not possible to hook into this. So to make this work I handled the PreviewMouseLeftButtonDown event on the LabelPresenter inside the FieldChooser and the PreviewMouseLeftButtonUp event on the ToolWindow that contains the FieldChooser. When the button down event fires, I grab the Field and store it. In the button up event, as long as there's a valid Field I check to see if the mouse was released above the ColumnsFieldDropAreaControl. If it was released above this, it adds the appropriate dimension to the XamPivotGrid.DataSource.Columns collection.
I have attached my sample for your consideration. Let me know if you have any questions on this.
Thanks Rob this works well. Thanks for this, also is there any way we can drag from the columns in the data grid to this pivot grid too. I tried this and this breaks the grouping functionality. Any advice here ? Thanks so much for your help in advance!!!
If you can please post some sample code for this. Thanks again Rob.
I tried putting a DragSource handler in the overriden Label Presenter style, this does the job for the Grid and the field chooser, but breaks the grouping functionality which we very much need. Any other clues would be greatly appreciated.
You probably overrode the default drag/drop functionality which means groupby won't work along with any of the other drag features the grid has. It's possible to setup my code to work with the normal LabelPresenters in the XamDataGrid but there is a slight issue where dragging the label outside of the grid and dropping it causes the Field to become hidden. The cursor also changes to an 'X' to indicate this. I haven't found a way to disable the cursor change but you can keep the Field from being hidden by handling the FieldPositionChanging event and canceling that. Take a look at my new sample. I basically just reused the code from the previous sample.
Hey Rob,
Thanks for your great work putting up this sample. This works partially. But like you say the 'X' sign is there, and also the dragging out column functionality breaks. Anywhere to get rid of this X sign, in the pivot area. It doesn't look droppable then. Or is this not achievable given the current internal drag and drop datagrid framework?
Cheers,
Anand