A voir également:
- Application mobile en Xamarin (c#)
- Nommez une application d'appel vidéo ou de visioconférence - Guide
- Desinstaller application windows - Guide
- Chaine tnt gratuite sur mobile - Guide
- Comment supprimer une application préinstallée sur android - Guide
- Windows application démarrage - Guide
3 réponses
Bonjour
Quel millésimes de VS Community?
Deux choses à essayer
Quel millésimes de VS Community?
Deux choses à essayer
- dans MaimPage, ajoute un bouton dont l’action est d'ouvrir la page de login, ça c’est pour vérifier qu’il n’y a pas de problème spécifique avec cette page.
- si le premier test est OK, il faut que tu expliques à ton projet que la page de démarrage n’est pas celle par défaut. Avec Xamarin, je ne sais pas faire, mais pour un projet wpf (avec du xaml aussi) c’est dans les propriétés du projet. Commence par chercher là
Bonsoir,
Je reviens sur vos suggestions concernant mon problème.
Tout d'abord, j'utilise Visual Studio community 2022.
J'ai mis un bouton dans le MainPage et il est sensé ouvir le LoginPage mais ça ne marche pas.
Dès que je compile, ça m'affiche juste les champs et le bouton. En gros c'est que la MainPage.xaml qui est compilée.
Je n'ai pas encore trouvé comment changer la mainPage par défaut.
Le code de ladite MainPage.xaml est :
²
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="mobileApp.MainPage"
Title ="Welome to Application !!" BackgroundColor="White">
<ContentPage.Content>
<StackLayout>
<Label Text="LOGIN" HorizontalOptions="Center" FontSize="Title" TextColor="Blue" Margin="0,30,0,10"/>
<Entry x:Name="UserNameEntry" Text="{Binding UserName}" Placeholder="User Name" Margin="10,10"></Entry>
<Entry x:Name="PassWordEntry" Text="{Binding PassWord}" Placeholder="Password" Margin="10,10"></Entry>
<Label x:Name="LoginMessageLabel" Text="{Binding LoginMessage, Mode=OneWay}" IsVisible="{Binding TurnLoginMessage}" />
<Button x:Name="LoginButton" Text="Login" TextColor="Wheat" BackgroundColor="Green"
Command="{Binding cmdLogin}"/>
<Button x:Name="CreateAccount" Text="Create Account" TextColor="Wheat" BackgroundColor="Gray"
Command="{Binding cmdCreateAccount}"/>
</StackLayout>
</ContentPage.Content>
</ContentPage>
Le code du MainPage.xaml.cs est :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace mobileApp
{
public event PropertyChangingEventHandler PropertyChanged;
public Command cmdLogin { get; set; }
public Command cmdCreateAccount { get; set; }
public partial class MainPage : ContentPage
{
public MainPage()
{
cmdLogin = new Command(gotoLoginPage);
cmdCreateAccount = new Command(gotoCreateAccount);
}
private void gotoLoginPage(object obj)
{
/// if(ilog.Login(UserName, Password)
App.Current.LoginPage.Navigation.PushAsync(new LoginPage());
}
private String userName;
public String UserName
{
get { return userName; }
set
{
UserName = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("UserName"));
}
}
private String password;
public String Password
{
get { return password; }
set
{
password = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Password"));
}
}
}
}
Je reviens sur vos suggestions concernant mon problème.
Tout d'abord, j'utilise Visual Studio community 2022.
J'ai mis un bouton dans le MainPage et il est sensé ouvir le LoginPage mais ça ne marche pas.
Dès que je compile, ça m'affiche juste les champs et le bouton. En gros c'est que la MainPage.xaml qui est compilée.
Je n'ai pas encore trouvé comment changer la mainPage par défaut.
Le code de ladite MainPage.xaml est :
²
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="mobileApp.MainPage"
Title ="Welome to Application !!" BackgroundColor="White">
<ContentPage.Content>
<StackLayout>
<Label Text="LOGIN" HorizontalOptions="Center" FontSize="Title" TextColor="Blue" Margin="0,30,0,10"/>
<Entry x:Name="UserNameEntry" Text="{Binding UserName}" Placeholder="User Name" Margin="10,10"></Entry>
<Entry x:Name="PassWordEntry" Text="{Binding PassWord}" Placeholder="Password" Margin="10,10"></Entry>
<Label x:Name="LoginMessageLabel" Text="{Binding LoginMessage, Mode=OneWay}" IsVisible="{Binding TurnLoginMessage}" />
<Button x:Name="LoginButton" Text="Login" TextColor="Wheat" BackgroundColor="Green"
Command="{Binding cmdLogin}"/>
<Button x:Name="CreateAccount" Text="Create Account" TextColor="Wheat" BackgroundColor="Gray"
Command="{Binding cmdCreateAccount}"/>
</StackLayout>
</ContentPage.Content>
</ContentPage>
Le code du MainPage.xaml.cs est :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace mobileApp
{
public event PropertyChangingEventHandler PropertyChanged;
public Command cmdLogin { get; set; }
public Command cmdCreateAccount { get; set; }
public partial class MainPage : ContentPage
{
public MainPage()
{
cmdLogin = new Command(gotoLoginPage);
cmdCreateAccount = new Command(gotoCreateAccount);
}
private void gotoLoginPage(object obj)
{
/// if(ilog.Login(UserName, Password)
App.Current.LoginPage.Navigation.PushAsync(new LoginPage());
}
private String userName;
public String UserName
{
get { return userName; }
set
{
UserName = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("UserName"));
}
}
private String password;
public String Password
{
get { return password; }
set
{
password = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Password"));
}
}
}
}
J'ai mis un bouton dans le MainPage et il est sensé ouvir le LoginPage mais ça ne marche pas.
Dès que je compile, ça m'affiche juste les champs et le bouton
OK, mais tu ne dis pas ce qu'il se passe quand tu cliques sur le bouton....
En gros c'est que la MainPage.xaml qui est compilée.non ça c'est pas possible, tout ce qui est dans le projet est compilé. Mais à ce stade seule cette page est affichée, c'est pas la même chose.
C'est comme un livre, si tu ne l'ouvres pas, tu ne verras que la couverture.
Pour tes prochains posts, merci d'utiliser les balises de code, voir ce court tuto https://codes-sources.commentcamarche.net/faq/11288-les-balises-de-code
Merci infiniment