I'm working on a Xamarin Forms Portable project where i have a Splash-Screen, a login page and a dashboard.
If i login correctly to the app i'm storing the user on a Sqlite database.
When i try to login and the user is saved on the database i should go directly to the Dashboard (Master-Detail Page).
In Android this is working correctly but in Windows it doesn't work. This is the code of my splash screen:
public class SplashScreen : ContentPage
{
public SplashScreen()
{
this.Padding = new Thickness(20, Device.OnPlatform<double>(40, 20, 20), 20, 20);
StackLayout panel = new StackLayout
{
VerticalOptions = LayoutOptions.FillAndExpand,
HorizontalOptions = LayoutOptions.FillAndExpand,
Orientation = StackOrientation.Vertical,
Spacing = 15,
};
panel.Children.Add(new Image
{
Aspect = Aspect.AspectFit,
Source = Device.OnPlatform(
iOS: ImageSource.FromFile("Resources/login.png"),
Android: ImageSource.FromFile("login.png"),
WinPhone: ImageSource.FromFile("Assets/login.png"))
}
);
panel.Children.Add(new Label
{
Text = "Splash",
});
this.Content = panel;
loguearseSiSePuede();
}
private async void loguearseSiSePuede()
{
UserLoginDB userDB = new UserLoginDB();
IEnumerable<UserLogin> users = userDB.getUsers();
var items = users.ToList();
Debug.WriteLine("usuario: " + items.Count());
if (items.Count() > 0)
{
var secondpage = new MasterDetail();
await Navigation.PushAsync(secondpage);
}
else
{
var secondpage = new Login();
await Navigation.PushAsync(secondpage);
}
}
}
The log Debug.WriteLine("usuario: " + items.Count()); is printing 1, so the user is stored correctly in the database but on, Windows the app loads the splashscreen and it won't navigate to any screen.
Does anyone knows why is this not working on Windows?
Thanks in advance