1

Does exist a similar EventToCommand (behavior's) on Android?

Example Silverlight/WPF:

<i:Interaction.Triggers>
                      <i:EventTrigger EventName="Click">
                        <Commanding:EventToCommand Command="{Binding DataContext.EditEventTypeCommand,
                                                                                             RelativeSource={RelativeSource AncestorType=telerik:RadGridView}}"
                                                   CommandParameter="{Binding}"
                                                   PassEventArgsToCommand="True" />
                      </i:EventTrigger>
</i:Interaction.Triggers>
Stuart
  • 66,722
  • 7
  • 114
  • 165
Andrew Andreev
  • 394
  • 4
  • 13

2 Answers2

1

If you are using mvvmcross, then bindings exist for all events which have EventHandler signatures - so you can just use bindings like:

'Click':{'Path':'MyViewModelCommand'}

There are plenty of examples of this in the samples, plus there are several questions oh here - search for MvvmCross and click.

If you need to bind to an event which has an EventHandler<T> signature then you can add this yourself - see mvvmcross touch command binding in android

Community
  • 1
  • 1
Stuart
  • 66,722
  • 7
  • 114
  • 165
  • I create cusotm bindings for GridView. How do I redeclaration ItemCommand? So to return the chosen Item. – Andrew Andreev Oct 29 '12 at 17:31
  • I have no idea what you are asking. Try the other questions on here or the samples. Or try writing a new full question. – Stuart Oct 29 '12 at 17:56
0

I'm not sure I have understood your question (I don't know Silverlight) but you can do as follows:

In your XML:

<Button ...
android:onClick="onMyButtonClicked".../>

In your java file

public void onMyButtonClicked(View sender) { ... }

There are no other ways to specify event handlers in Android XML, I think. You can specify a lot of properties though.

Alexander Kulyakhtin
  • 47,782
  • 38
  • 107
  • 158