【发布时间】:2015-06-17 15:34:07
【问题描述】:
我在我的项目中使用 MVVM Light,我想知道是否有任何方法可以将 RelayCommand 与所有控件(例如 ListView 或 Grid)一起使用。
这是我当前的代码:
private void Item_Tapped(object sender, TappedRoutedEventArgs e)
{
var currentItem = (TechItem)GridControl.SelectedItem;
if(currentItem != null)
Frame.Navigate(typeof(TechItem), currentItem);
}
我想把这段代码移到Model并使用RelayCommand,但是ListView、Grid等控件没有Command和CommandParameter属性。
MVVM Light 在这种情况下可以做什么?
【问题讨论】:
-
您可以使用
Interaction.Behaviors将事件绑定到命令How to add Command Behavior in windows store 8.1 MVVM application -
能否将项目模板设为按钮?
-
@har07,谢谢。它对我有帮助
标签: xaml mvvm windows-8.1 mvvm-light