This question is locked. New answers and comments are not allowed.
Hi,
I'm using the RadDataBoundListBox with a RadContextMenu inside.
I would like to pass the item ,to my viewmodel, of the list box where I opened the menu.
The command is fired but the paramenter is always null.
I also read others thread but I didn't find any solution.
This is my xaml code:
<telerikPrimitives:RadDataBoundListBox x:Name="myLista" ItemContainerStyle="{StaticResource ItemContainerStyle}" ItemTemplate="{StaticResource ListBoxNewItemTemplate}" ItemsSource="{Binding ListaItems}">
<telerikPrimitives:RadContextMenu.ContextMenu>
<telerikPrimitives:RadContextMenu>
<telerikPrimitives:RadContextMenuItem Content="Modifica" Command="{Binding Modifica}" CommandParameter="{Binding}"/>
<telerikPrimitives:RadContextMenuItem Content="Rimuovi" Command="{Binding Rimuovi}" CommandParameter="{Binding}"/>
</telerikPrimitives:RadContextMenu>
</telerikPrimitives:RadContextMenu.ContextMenu>
<i:Interaction.Triggers>
<i:EventTrigger EventName="ItemTap">
<command:EventToCommand Command="{Binding ItemClick}"
CommandParameter="{Binding SelectedItem, ElementName=myLista}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</telerikPrimitives:RadDataBoundListBox>
This is my viewmodel code:
private RelayCommand<MyViewModel> _modifica;
public RelayCommand<MyViewModel> Modifica
{
get
{
return _modifica
?? (_modifica = new RelayCommand<MyViewModel>(
item =>
{
if (item != null)
{
...do something
}
}
));
}
}
I'm using the RadDataBoundListBox with a RadContextMenu inside.
I would like to pass the item ,to my viewmodel, of the list box where I opened the menu.
The command is fired but the paramenter is always null.
I also read others thread but I didn't find any solution.
This is my xaml code:
<telerikPrimitives:RadDataBoundListBox x:Name="myLista" ItemContainerStyle="{StaticResource ItemContainerStyle}" ItemTemplate="{StaticResource ListBoxNewItemTemplate}" ItemsSource="{Binding ListaItems}">
<telerikPrimitives:RadContextMenu.ContextMenu>
<telerikPrimitives:RadContextMenu>
<telerikPrimitives:RadContextMenuItem Content="Modifica" Command="{Binding Modifica}" CommandParameter="{Binding}"/>
<telerikPrimitives:RadContextMenuItem Content="Rimuovi" Command="{Binding Rimuovi}" CommandParameter="{Binding}"/>
</telerikPrimitives:RadContextMenu>
</telerikPrimitives:RadContextMenu.ContextMenu>
<i:Interaction.Triggers>
<i:EventTrigger EventName="ItemTap">
<command:EventToCommand Command="{Binding ItemClick}"
CommandParameter="{Binding SelectedItem, ElementName=myLista}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</telerikPrimitives:RadDataBoundListBox>
This is my viewmodel code:
private RelayCommand<MyViewModel> _modifica;
public RelayCommand<MyViewModel> Modifica
{
get
{
return _modifica
?? (_modifica = new RelayCommand<MyViewModel>(
item =>
{
if (item != null)
{
...do something
}
}
));
}
}