带 EventToCommand 的图钉

发布于 2024-10-04 22:40:39 字数 1020 浏览 0 评论 0原文

我正在尝试调整Windows Phone 7 TrainingKit 中包含的UsingBingMaps 示例(http://www.microsoft.com/downloads/en/details.aspx?displaylang=en&FamilyID=ca23285f-bab8-47fa-b364-11553e076a9a) 到使用 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 与 Pushpin 对象一起使用吗?

I am trying to adapt the UsingBingMaps sample included in the Windows Phone 7 TrainingKit (http://www.microsoft.com/downloads/en/details.aspx?displaylang=en&FamilyID=ca23285f-bab8-47fa-b364-11553e076a9a) to use MVVM-Light toolkit. I am trying to set up a command to the Pushpin's MouseLeftButtonUp event using EventToCommand but the command does not get executed. Below is the code of the pushpin:

<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>

Am I missing anything? Was anyone able to use EventToCommand with the Pushpin object?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

溇涏 2024-10-11 22:40:39

您想用该命令做什么?

我可以使用它来获取触发命令,但我似乎无法从传递的参数中获取对象详细信息。

我已经在 silverlight 中使用了它,我认为它可以直接在 WP7 中使用(如果我错了,请纠正我)

        <i:Interaction.Triggers>
         <i:EventTrigger EventName="MouseLeftButtonUp">
              <cmd:EventToCommand Command="{Binding Path=pinSelCommand}" PassEventArgsToCommand="True" ></cmd:EventToCommand>
         </i:EventTrigger>
    </i:Interaction.Triggers>

在我的 viewmodel 构造函数中,我

PolySelCommand = new RelayCommand<MouseButtonEventArgs>(PolySelCommandExecute);

在 viewmodel 类中

public RelayCommand<MouseButtonEventArgs> pinSelCommand{ get; set; }
private voidpinSelCommandExecute(MouseButtonEventArgs e)
{
   // < Your code >
}

希望这会有所帮助。如果您弄清楚如何传递对象详细信息,请发回,因为我在这篇文章中遇到问题< /a>

What are you trying to do with the command?

I can get a command to fire using this, but i cant seem to get the object details from the arguments passed.

I have used this in silverlight, which I think is directly usable in WP7 (please correct me if I am mistaken)

        <i:Interaction.Triggers>
         <i:EventTrigger EventName="MouseLeftButtonUp">
              <cmd:EventToCommand Command="{Binding Path=pinSelCommand}" PassEventArgsToCommand="True" ></cmd:EventToCommand>
         </i:EventTrigger>
    </i:Interaction.Triggers>

In my viewmodel constructor I have

PolySelCommand = new RelayCommand<MouseButtonEventArgs>(PolySelCommandExecute);

in viewmodel class

public RelayCommand<MouseButtonEventArgs> pinSelCommand{ get; set; }
private voidpinSelCommandExecute(MouseButtonEventArgs e)
{
   // < Your code >
}

Hope this helps out. If you work out how to pass the object details, please post back as I have problem on this post

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文