我正在使用mvvm模式玩我的第一个wpf项目。 我有用于WPF的Microsoft Ribbon,我无法在MainWindowViewModel中触发我的方法。 我正按照此处的说明进行操作:http://msdn.microsoft.com/en-us/magazine/dd419663.aspx
MainWindow.xaml
<ribbon:RibbonButton x:Name="Button1" LargeImageSource="Images\home32.png" Label="Opret klub" Command="{Binding Path=CreateNewClub1}" />
MainWindowViewModel
public RelayCommand CreateNewClub1()
{
return new RelayCommand(param => this.CreateNewClub());
}
我无法解决方法CreateNewClub1()。我错过了什么?
答案 0 :(得分:1)
CreateNewClub1必须是属性,而不是方法:
public RelayCommand CreateNewClub1
{
get
{
return new RelayCommand(param => this.CreateNewClub());
}
}