Hi,
I have a xam data grid in Page1 and other in Page2 . i need to drag records from one grid and drop to other grid,using MVVM pattern in WPF.
Any Sample Applications would help Thanks.
Hi Matt
Thanks for the Sample Application
I am working with xamdatagrid. and could either see the Drag Icon or none of the events are triggering when i select the row and start the Drag Operation.
Below is my XAML Code.
<cts:XamDataGrid x:Name="dgDeviceList2" GroupByAreaLocation="None" SelectedItems="{Binding SelectedElements, Mode=OneWayToSource}" DataSource="{Binding AddIOComponents}" BorderThickness="1" BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}" ScrollingMode="Immediate" Margin="0,53,0,35" AssigningFieldLayoutToItem="xamDataGrid1_AssigningFieldLayoutToItem"> <ig:DragDropManager.DragSource> <ig:DragSource DragEnter="DragSource_DragEnter" IsDraggable="True" DragChannels="ChannelA" DragTemplate="{StaticResource dt}" DragOver="DragSource_DragOver" Drop="DragSource_Drop"/> </ig:DragDropManager.DragSource>
</cts:XamDataGrid>
Do i need to do something differently for xamdata grid.
Hi Matt,
In the sample Application drag & drop is not working, None of the Events are fired
I am using InfragisticsWPF4.DragDrop.v12.1
hi jerovsek
i am also stuck in same problem so can you please share your code snippet with me
Thanks,
Atul
Thanks Matt .
ObservableCollection leagues = ndr.DataPresenter.DataSource as ObservableCollection;
worked out exactly as per our requirement.
HI,
If you are using the DataRecordPresenter you could get the viewmodel collection from that object's DataPresenter.DataSource property, Code Snippet:
ObservableCollection leagues = ndr.DataPresenter.DataSource as ObservableCollection; (probably bestway)
or you could get it from the Application.Current.Resources.
Code Snippet:
VM vm = Application.Current.Resources["vm"] as VM;
or you could get it from the Windows resources.
Code Snippet: Vm vm = Application.Current.Windows[0].Resources["vm"] as Vm;
Sincerely, Matt Developer Support Engineer
Matt,
I have Implemented events as below for XAMDataGRID
DataRecordPresenter dp; DataRecordPresenter dragOver; private void DragSource_DragStart(object sender, Infragistics.DragDrop.DragDropStartEventArgs e) {
dp = Utilities.GetAncestorFromType(e.DragSource as DependencyObject, typeof(DataRecordPresenter), false) as DataRecordPresenter;
}
//This is giving me the Dragged element and the item i need to Drop
private void DragSource_Drop(object sender, Infragistics.DragDrop.DropEventArgs e) {
dragOver = Utilities.GetAncestorFromType(e.DropTarget as DependencyObject, typeof(DataRecordPresenter), false) as DataRecordPresenter; Employee targetElement = dragOver.DataRecord.DataItem as Employee ; Employee sourceElement = dp.DataRecord.DataItem as Employee ; }
The Issue is i have seperate viewmodels for each drag & drop windows and i am not able to identify the view model of the drop window.
I can just create an instance of the viewmodel like
DropVm vm = new dropVM(); and drop my target element into my observablecollection property , But
our requirement is i can drag from a source and drop into any view which accepts my object. So i need to identify the dropTarget(it's view model).
Do we need to shift to XAM GRID for achieving Drag Drop Functionality b/w two Windows. Do we have any work around If not then we amy shift from xam data grid to xam grid. Please advice .