将所选项目作为参数发送到视图模型中的方法 [WPF、Caliburn]
我有这个问题。我在 WPF 中使用 calibburn micro。在视图中,我有列表框,并且我绑定在视图模型中的事件 MouseDoubleClick 方法上。我想作为参数发送选定的列表框项目。但我不知道该怎么做。
在视图中我有这个:
<ListBox Name="Friends"
SelectedItem="Key"
Style="{DynamicResource friendsListStyle}"
Grid.Row="2"
Margin="4,4,4,4"
Micro:Message.Attach="[MouseDoubleClick]=[Action SendRp(Key)]"
PreviewMouseRightButtonUp="ListBox_PreviewMouseRightButtonUp"
PreviewMouseRightButtonDown="ListBox_PreviewMouseRightButtonDown"
MouseRightButtonDown="FriendsListBoxMouseRightButtonDown"/>
在视图模型中我有这个方法:
public void SendRp(string key)
{
MessageBox.Show(key);
}
任何进展,谢谢。
I have this problem. I use caliburn micro in WPF. In view I have listbox, and I bind on event MouseDoubleClick method in view-model. I would like send as parameter selected listbox item. But I don’t know how do it.
in view I have this:
<ListBox Name="Friends"
SelectedItem="Key"
Style="{DynamicResource friendsListStyle}"
Grid.Row="2"
Margin="4,4,4,4"
Micro:Message.Attach="[MouseDoubleClick]=[Action SendRp(Key)]"
PreviewMouseRightButtonUp="ListBox_PreviewMouseRightButtonUp"
PreviewMouseRightButtonDown="ListBox_PreviewMouseRightButtonDown"
MouseRightButtonDown="FriendsListBoxMouseRightButtonDown"/>
In view model I have this method:
public void SendRp(string key)
{
MessageBox.Show(key);
}
Any advance, thank.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我对 caliburn 不太了解,但我猜你还必须写
一下,你应该省略
SelectedItem="Key"
或使用与 ViewModel 的绑定,如下所示:I dont know much about caliburn but my guess is you have to write
also you should either omit the
SelectedItem="Key"
or use a binding to your ViewModel like this: