I am using System.Windows.interactivity.dll to get mouse events in my ViewModel in the following manner.
I Agree with Aghilas. That's how it's done. I improved upon Aghilas's code to clarify what was missing. note that "i:InvokeCommandAction.CommandParameter" must be put inside the invokeCommandAction declaration.
<ListBox x:Name="listBox" ItemsSource="{Binding HeaderList}" DisplayMemberPath="Text" Width="Auto" Margin="0,0,0,300" Height="Auto" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseLeftButtonUp">
<i:InvokeCommandAction Command="{Binding MouseLeftButtonUpCommand}">
<i:InvokeCommandAction.CommandParameter>
<MultiBinding Converter="{StaticResource XAMLResourceAddConverter}">
<Binding ElementName="listBox" Path="SelectedItem"/>
<Binding ElementName="listBox" Path="SelectedItem"/>
</MultiBinding>
</i:InvokeCommandAction.CommandParameter>
</i:InvokeCommandAction>
</i:EventTrigger>
</i:Interaction.Triggers>
</ListBox>
You can try with custom Converter and MultiBinding
<CommandParameter>
<MultiBinding Converter="{StaticResource CustomConverter}">
<Binding ElementName=".." Path=".."/>
<Binding ElementName=".." Path=".."/>
</MultiBinding>
</CommandParameter>
Converter
class CustomConverter : IMultiValueConverter
{
public object Convert (object[] Values, Type Target_Type, object Parameter, CultureInfo culture)
{
var findCommandParameters = new FindCommandParameters();
findCommandParameters.Property1 = (string)values[0];
findCommandParameters.Property1 = (string)values[1];
return findCommandParameters;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
Parameters
public class FindCommandParameters
{
public string Property1 { get; set; }
public string Property2 { get; set; }
}