There are no errors. I am trying to learn MVVM. The setup is simple. I get no output when clicking on the button. Xaml should be ok since I have produced interactions part in Blend by dragging behavior to the button. Note: My intention to use methods, but not command, since commands cover only click, but not for example DoubleClick.
<Window
x:Class="MVVM_1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:local="clr-namespace:MVVM_1"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="MainWindow"
Width="525"
Height="350"
mc:Ignorable="d"
>
<Window.DataContext>
<local:ViewModel/>
</Window.DataContext>
<Grid>
<Button x:Name="button"
Width="75"
Margin="198,168,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Content="TestMethod">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseLeftButtonDown" SourceName="button">
<ei:CallMethodAction MethodName="MethodTesting"
TargetObject="{Binding}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</Grid>
using System.Windows;
namespace MVVM_1
{
public class ViewModel
{
public static void MethodTesting()
{
MessageBox.Show("Success!");
}
}
}