Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Extend BindCommand to allow passing EventArgs for any Event in Xamarin Forms #1228

Closed
escamoteur opened this issue Jan 14, 2017 · 5 comments
Closed
Labels

Comments

@escamoteur
Copy link

Do you want to request a feature or report a bug?
Improvement

What is the current behavior?
If you use BindCommand to bind to another event than the default one your command does not receive the command arguments.

Like when I tried to bind to the Swiped Event of Mr.Gesture

this.BindCommand(ViewModel, vm => vm.SwipeCommand, v => v.TouchHandler, nameof(TouchHandler.Swiped));

A XF Command will receive SwipeEventArgs. But a ReactiveCommand doesn't

So there seems to be two shortcomings in the current implementation.

  1. Eventargs are not passed
  2. It's not possible to define custom Eventargs like I can do in Xaml that should be passed

Also I question if passing the EventName of a non standard event is the best solution or if it would be better directly to pass the Control events as we have access in the View to the Control already.

Which versions of ReactiveUI, and which platform / OS are affected by this issue? Did this work in previous versions of ReativeUI? Please also test with the latest stable and snapshot (http://docs.reactiveui.net/en/contributing/snapshot/index.html) versions.
RxUI 7 with Xamarin Forms

@ghuntley
Copy link
Member

ghuntley commented Jan 31, 2017

Howdy @escamoteur; some quick thoughts. Take a quick peek into the source code behind reactiveui-events and you'll see that there is a convention that should solve your particular problem.

Instead of binding, codegen your extension methods using the supplied eventbuilder console app or create them yourself; they are pretty simple and do something along the lines of:

viewCtor()
{
    this.Label.Events().Swiped().[Subscribe/ExecuteCommand]...AddTo(disposables) // don't forget to dispose the subscription
}

@escamoteur
Copy link
Author

Ok, that is a sort of Workaround. Still I think if we offer CommandBinding we should be able to deal with this too

@vector-man
Copy link

vector-man commented Apr 10, 2017

Is this also impossible in Windows Forms? I cannot seem to figure it out based on available documentation, but the workaround helped a little.

@ghuntley
Copy link
Member

@vector-man the remarks over at #1228 (comment) apply to windows forms as well. Compose your event stream, subscribe to it and then execute the logic as need be.

@escamoteur
Copy link
Author

@ghuntley so you decided that this issue is no loner worth to consider?

@lock lock bot added the outdated label Jun 25, 2019
@lock lock bot locked and limited conversation to collaborators Jun 25, 2019
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants