Binding Row Dropped Event to a command in XAML

Hi,

I'd like to handle the event RowDragDropController.Dropped by a command because I use MVVM pattern. 

I tried with my code below, but the command doesn't trigger. What I do wrong?


<syncfusion:SfDataGrid Name="sfDataGrid"
   Width="Auto" Height="Auto" HorizontalAlignment="Stretch"
   ItemsSource="{Binding PptFilesCollection, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
   AutoGenerateColumns="False"
RowDropIndicatorMode="Line"
AllowDraggingRows="True"
   AllowDrop="True"
ShowRowHeader="True">
<i1:Interaction.Triggers>
<i1:EventTrigger EventName="Dropped">
<i1:InvokeCommandAction Command="{Binding TestCommand}" />
</i1:EventTrigger>
</i1:Interaction.Triggers>
</syncfusion:SfDataGrid>

Regards

Jakub


2 Replies 1 reply marked as answer

VS Vijayarasan Sivanandham Syncfusion Team February 7, 2022 03:37 PM UTC

Hi Jakub Olichwier,

 
Currently, we are analyzing your requirement of “Binding Row Dropped Event to a command in XAML” We will validate and update you the details on or before February 9, 2022. 
  
We appreciate your patience until then. 

Regards, 
Vijayarasan S 



VS Vijayarasan Sivanandham Syncfusion Team February 9, 2022 02:39 PM UTC

Hi Jakub Olichwier,

Your requirement to binding the RowDragDropController.Dropped event to a command in SfDataGrid can be achieved by set the SourceObject property in EventTrigger like below code example, 

<syncfusion:SfDataGrid x:Name="sfDataGrid"   
                               AllowDraggingRows="True" 
                               AllowDrop="True"                               
                               ItemsSource="{Binding Orders}" >            
             <i:Interaction.Triggers > 
                <i:EventTrigger EventName="Dropped" SourceObject="{Binding RowDragDropController,ElementName=sfDataGrid}" > 
                    <i:InvokeCommandAction Command="{Binding Path=DroppedEventCommand}"   
                                           CommandParameter="{Binding}"   /> 
                </i:EventTrigger> 
            </i:Interaction.Triggers>           
</syncfusion:SfDataGrid>    

Please let us know if you have any concerns in this. 

Regards, 
Vijayarasan S 


Marked as answer
Loader.
Up arrow icon