A Microsoft framework for building cross-platform mobile apps using .NET and C# with native performance and user interfaces.
Hello,
Welcome to our Microsoft Q&A platform!
When user log out and after log in, information in the header don't update.
A simple method is to use MessagingCenter to achieve this.
You can refer the following code:
private void UserLogin_Event(object sender, EventArgs e)
{
// other code
MessagingCenter.Send<object>(new FlyoutHeader(), "hi");
}
The FlyoutHeader.xaml.cs
public partial class FlyoutHeader : ContentView
{
public FlyoutHeader()
{
InitializeComponent();
MessagingCenter.Subscribe<object>(this, "hi", (sender) => {
if (App.newLogINModel.IsLogin)
{
mNameLabel.Text = App.newLogINModel.Name;
mHeadImage.Source = App.newLogINModel.ImageSource;
}
else
{
mNameLabel.Text = "";
mHeadImage.Source = "default.png";
}
});
}
}
The FlyoutHeader.xaml
<?xml version="1.0" encoding="UTF-8"?>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Xaminals.Controls.FlyoutHeader"
HeightRequest="200">
<Grid BackgroundColor="Black">
<Image
x:Name="mHeadImage"
Aspect="AspectFill"
Source="xamarinstore.jpg"
Opacity="0.6" />
<Label
x:Name="mNameLabel"
Text="Animals"
TextColor="White"
FontAttributes="Bold"
HorizontalTextAlignment="Center"
VerticalTextAlignment="Center" />
</Grid>
</ContentView>
Best Regards,
Jessie Zhang
---
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.