none
WPF drag and drop for multiple rows from datagrid xaml MVVM pattern RRS feed

  • Question

  • I have tried to drag and drop but its not properly working. i need one class for drag and drop implementation that should be reused in all other data grids in my project. please help me to give the samples.
    Friday, January 17, 2020 10:47 AM

All replies

  • Hi,

    If you want to pass values between multiple DataGrids in MVVM pattern,I suggest you use System.Windows.Interactivity:

     xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"

     <DataGrid AllowDrop="True" Name="DataGrid1">
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="PreviewMouseLeftButtonDown">
                        <i:InvokeCommandAction Command=""/>
                    </i:EventTrigger>
                    <i:EventTrigger EventName="DragOver">
                        <i:InvokeCommandAction Command=""/>
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </DataGrid>
            <DataGrid AllowDrop="True" Name="DataGrid2"  >
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="Drop">
                        <i:InvokeCommandAction Command=""/>
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </DataGrid>

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, January 20, 2020 8:02 AM
    Moderator
  • Hi Alex,

    thank you for your reply,  i am stuck with treeviewitem.expanded event in caliburn miro mvvm pattern, when i am trying like this. its not hit that method. coould you please help me to resolve this issue?

    <TreeView Grid.Column="0" ItemsSource="{Binding TreeViewCollection,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" AllowDrop="True"
                      FontSize="12"  cal:Message.Attach="[Event TreeViewItem.Expanded] = [Action SetSelectedItem($this)]" />

    Regards

    Abirami S.

    Wednesday, February 19, 2020 11:45 AM