Raj*_*air 1 windows-phone-7 mvvm-light
这适用于WP7.我在列表框itemtemplate中有一个按钮.在关联的ViewModel中,我有RelayCommand,它已经绑定到Button的Click事件(使用MVVMLight EventToCommand).我想要的只是在单击按钮时传入ListBox的ListItem.
有任何想法吗?
小智 5
在xaml CommandParameter="{Binding}"中使用,它会将您选择的ListItem传递给命令
然后在视图模型中
private RelayCommand<ListItem> _command;
public RelayCommand<ListItem> Command
{
get
{
return _command ?? (_command = new RelayCommand(Method));
}
}
public void Method(ListItem item)
{
...
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
319 次 |
| 最近记录: |