0

How to pass CommandParameter on holed item?

my xaml code

   <ListView  Grid.Row="1" Name="ProfilesListView" SelectedItem="{Binding SelectedUser,Mode=TwoWay}" ItemsSource="{Binding Path=ViewAllProfile,Mode=TwoWay}">
                <ListView.ItemsPanel>
                    <ItemsPanelTemplate>
                        <ItemsWrapGrid Orientation="Horizontal" HorizontalAlignment="Center">
                        </ItemsWrapGrid>
                    </ItemsPanelTemplate>
                </ListView.ItemsPanel>
                <I:Interaction.Behaviors>
                    <core:EventTriggerBehavior EventName="Holding">
                        <core:InvokeCommandAction Command="{Binding Path=HoldingCommand}" CommandParameter="{Binding ElementName=ProfilesListView,Path=SelectedItem}"  ></core:InvokeCommandAction>
                    </core:EventTriggerBehavior>
                </I:Interaction.Behaviors>
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <StackPanel   Margin="10,0,0,0">
                            <Image  Margin="10" Source="{Binding ImageURL}"   Width="150" Height="150" >
                            </Image>
                            <TextBlock x:Name="userName"  Text="{Binding MenuName}" Foreground="White" HorizontalAlignment="Center"></TextBlock>
                        </StackPanel>
                    </DataTemplate>
                </ListView.ItemTemplate>               
            </ListView>

my viewmodel is .i am not getting the holding item details .how to solve this

 _HoldingCommand = new RelayCommand<object>(HoldedUser);
suresh
  • 113
  • 11

1 Answers1

0

Not sure this can be done directly through MVVM binding. The holding event won't set the selected item straight away...

If you would register to the holding event and use code behind, you'll notice the 'holded' item is only known in the HoldingRoutedEventArgs - something like this:

private async void OnListViewHolding(object sender, HoldingRoutedEventArgs e)
{
   var selectedItemThroughHolding = e.OriginalSource.DataContext as ***Model;
}

So my suggestion would be to use this code behind event and reroute the selectedItem to the viewmodel there...

Depechie
  • 6,102
  • 24
  • 46