我正在尝试修改Windows phone7 TrainingKit (http://www.microsoft.com/downloads/en/details.aspx?displaylang=en&FamilyID=ca23285f-bab8-47fa-b364-11553e076a9a)中包含的UsingBingMaps示例以使用MVVM-Light工具包。我正在尝试使用EventToCommand为图钉的MouseLeftButtonUp事件设置一个命令,但是该命令没有被执行。下面是图钉的代码:
<my:Pushpin Style="{StaticResource PushpinStyle}"
Location="{Binding Location}"
Background="{Binding TypeName, Converter={StaticResource PushpinTypeBrushConverter}}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseLeftButtonUp">
<cmd:EventToCommand Command="{Binding DataContext.PushpinClickCommand, ElementName=HomePage}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<Image Source="{Binding Icon}" />
</my:Pushpin>我错过了什么吗?有没有人能够将EventToCommand与图钉对象一起使用?
发布于 2011-05-24 19:42:48
你想用这个命令做什么?
我可以使用它获得一个触发命令,但我似乎无法从传递的参数中获取对象的详细信息。
我在silverlight中使用过这个,我认为它可以直接在WP7中使用(如果我错了,请纠正我)
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseLeftButtonUp">
<cmd:EventToCommand Command="{Binding Path=pinSelCommand}" PassEventArgsToCommand="True" ></cmd:EventToCommand>
</i:EventTrigger>
</i:Interaction.Triggers>在我的视图模型构造函数中,我有
PolySelCommand = new RelayCommand<MouseButtonEventArgs>(PolySelCommandExecute);在viewmodel类中
public RelayCommand<MouseButtonEventArgs> pinSelCommand{ get; set; }
private voidpinSelCommandExecute(MouseButtonEventArgs e)
{
// < Your code >
}希望这能帮上忙。如果你想出了如何传递对象的细节,请回帖,因为我有问题on this post
https://stackoverflow.com/questions/4293493
复制相似问题