0
votes

I need the currently visible ContentPage, that is bind to a viewmodel, as a CommandParameter for a view model's command.

Like:

<Button Text="Save" 
        Command="{Binding AddObjectAndClosePage}" 
        CommandParameter={Binding MyContentPage} />

But Xamarin does not support the ElementNamebinding. How can I use now my ContentPage as parameter?

1
The method was a property of my view model :). But nevertheless I learned that this approach is totally wrong. - Tobonaut

1 Answers

1
votes

Ok, it was completely my fault. My approach was breaking all rules of the mvvm pattern.

You can access the Navigationcontext in the command method in your viewmodel by writing:

Application.Current.MainPage.Navigation.PopModalAsync();

Lesson learned.