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

Best way to initialize Commands

$
0
0

Hi,

so far I always implemented Commands as public properties and initialized them in my Constructor like this:

    public class MainMenuPageModel : FreshBasePageModel
    {
        public MainMenuPageModel()
        {
            OpenRecipesCommand = new Command(async () => await CoreMethods.PushPageModel<RecipesMainPageModel>());

        }

        public Command OpenRecipesCommand { get; private set; }
   }

No I stumbled upon this solution:

    public Command AddContact {
        get {
            return new Command (async () => {
                await CoreMethods.PushPageModel<ContactPageModel> ();
            });
        }
    }

Is there any advantages/disadvantages in this solutions?

Cheers
Thomas


Viewing all articles
Browse latest Browse all 77050

Trending Articles