Issue
How to bring username show it at Shell with xamarin?
Solution
At first, you can try to set the LoginPage as the MainPage in the App.cs:
public App()
{
InitializeComponent();
MainPage = new Page1();
}
Then you can set the FlyoutHeader in the AppShell.xaml, such as:
<Shell.FlyoutHeader>
<Label x:Name="header" />
</Shell.FlyoutHeader>
And then you can change AppShell's construction method, such as:
public AppShell(string name)
{
InitializeComponent();
header.Text = name;
}
Finally, you can set the App.Current.MainPage as AppShell in the login button's clicked event in the LoginPage, such as:
private void Button_Clicked(object sender, EventArgs e)
{
string name = "";
App.Current.MainPage = new AppShell(name);
}
In addition, you can also try to use mvvm and bind a string variable which is in the viewmodel to the control which you want to show the username. And then change the variable's value in the button clicked event.
Answered By - Liyun Zhang - MSFT
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.