Click here to Skip to main content
15,921,577 members
Please Sign up or sign in to vote.
4.33/5 (3 votes)
See more:
I am using System.Windows.Interactivity.dll and Microsoft.Expression.Interaction.dll to do event handling in Viewmodel in my MVVM WPF project. below is the code inside my Xaml:
HTML
<ItemsControl ItemsSource="{Binding Path= HeaderList}" Grid.Row="0" Grid.Column="0" >
       <ItemsControl.ItemTemplate>
           <DataTemplate>
                 <TextBlock   Text="{Binding Text}" Width="100" HorizontalAlignment="Left" >
                     <i:Interaction.Triggers>
                         <i:EventTrigger EventName="PreviewMouseLeftButtonDown">
                            <ie:CallMethodAction MethodName="PrevMouseDownEventHandler" TargetObject="{Binding}" />
                         </i:EventTrigger>
                      </i:Interaction.Triggers>
               </TextBlock>
           </DataTemplate>
       </ItemsControl.ItemTemplate>
   </ItemsControl>

for this I added namespaces in the same Xaml.
HTML
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:ie="http://schemas.microsoft.com/expression/2010/interactions"

and in my viewmodel I have created a method having PrevMouseDownEventHandler name which is same as that of I mentioned as CallMethod inside EventTigger in the Xaml.

On running my application when I presses mouse button on TextBlock event is generated and look for PrevMouseDownEventHandler method and leave me into following exception:

Could not find method named 'PrevMouseDownEventHandler' on object of type 'string' that matches the expected signature.

this method is as below in my ViewModel.
C#
public void PrevMouseMoveEventHandler(object sender, MouseButtonEventArgs e)
    {
        // Some implementation here;  
    }

I don't have any idea where I am going wrong. Except this all the funtionalities inside Viewmodel is working fine for me. what would be possible solution for this?
Posted
Updated 25-Sep-12 22:09pm
v2

1 solution

see here

WPF DrawTools[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900