2

我有这个问题。我在 WPF 中使用 caliburn 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);
    }

任何提前,谢谢。

4

1 回答 1

6

我对caliburn了解不多,但我猜你必须写

Micro:Message.Attach="[MouseDoubleClick]=[Action SendRp(Friends.SelectedItem)]"

您也应该SelectedItem="Key"像这样省略或使用与您的 ViewModel 的绑定:

SelectedItem="{Binding Key}"
于 2010-12-15T13:29:27.207 回答