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

Commands and NavigationPage

$
0
0

Hello !

I am a beginner on Xamarin and Xamarin.Forms, and I am facing a behaviour I don't understand. Basically, my app only contains pages (using XAML), which you access from a default page by using Buttons. Here is one of it, from DemoPage.xaml (class DemoPage):

<Button 
    Text="Login"
    Command="{Binding GoToLoginPageCommand}" />

Here is the code of the related command, from the DemoViewModel.cs :
GoToLoginPageCommand = new Command(() => navigation.PushAsync(App.loginPage));

Then here the thing. In App.cs, this work great :
MainPage = new NavigationPage(new DemoPage());

But if I write this:

demoPage = new DemoPage();
MainPage = new NavigationPage(demoPage );

The command do not work, clicking on the button do nothing ... why ?

Note that every pages and viewmodels are static fields of the App class, and instanciated before calling MainPage = ...

Thanks in advance !


Viewing all articles
Browse latest Browse all 58056

Trending Articles



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