Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Xamarin.Forms.Labs - How to set Commands in constructor when using ViewFactory

$
0
0

HI,

I'm using ViewFactory to instantiate my Pages. The problem with this pattern is that the BindingContext gets set after the Page's constructor has been run, which is obvious, but this creates a problem if I want to bind set a control's command property to a command in my ViewModel inside the constructor.

From what I can tell I have the following options:
1. Use Lambdas and register to the desired control events and access my view model inside the lambda.
2. Inject the ViewModel through the constructor somehow.
3. Stop using ViewFactory.

I've read that I should try and not use lambdas because of cyclic dependency (weak and strong reference problems in iOS)?

Is there any best practice?


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>