3

So in WPF there is a CommandParameter attribute that you can use in your XAML code to send information about what is selected to your CS code to use.

I am trying to learn Windows Phone 7 programming and it seems very similar to WPF, so I thought I would try using CommandParameter, but this doesn't seem to work. Do you know of an equivalent thing to use? Below is some background on my project...

On the phone ApplicationBarMenuItem

<shell:ApplicationBarMenuItem x:Name="Download" Text="Download" Click="Download_Click"/>

I am trying to put a CommandParameter="{Binding Path=Id}" attribute like you can use in WPF to send the id of an image being populated in code for this pivot item that the image is on to my CS code so that I can do those functions in the menu based on which page I am on.

pongahead
  • 1,984
  • 3
  • 18
  • 21

3 Answers3

1

ApplicationBarMenuItem (and ApplicationBarIconButton) make things more complicated as they are not dependency objects (they extend Object directly), which means they can't have behaviors or triggers applied to them.

The WP7 Developer Guide (Prism for WP7) has a ApplicationBarButtonCommand behavior (ie. a Blend SDK Behavior) that can be applied to the ApplicationPage and will bind an ICommand to a ApplicationBarIconButton. You could easily created a MenuItem equivalent of it.

Richard Szalay
  • 83,269
  • 19
  • 178
  • 237
1

Command support is coming in Mango (version 7.1) the beta of which dropped earlier this week.

Peter Wone
  • 17,965
  • 12
  • 82
  • 134
0

Silverlight and WP7 don't have much support for commanding; just about only the Button supports it. You can use the EventToCommandBehavior from the MVVMLight Toolkit to bind a command to any event including the click event.

shf301
  • 31,086
  • 2
  • 52
  • 86