I have picker in my left menu navigation shell that change the main page language,
for example actually the app in English. When I change to French, it change and redirect to main page with French text.
The problem is when I press the back arrow in navigation page, it back to old language (English).
Here the shell navigation
<Shell ..>
<Shell.FlyoutHeader>
<Picker ItemsSource="{Binding MultiLang, Mode=TwoWay}" SelectedItem="{Binding SelectedLang}">
</Picker>
</Shell.FlyoutHeader>
<ShellContent x:Name="home"
Route="main"
ContentTemplate="{DataTemplate home:Dashboard}" />
</Shell>
and this is the method that redirects to the main page:
private async void ChangeLange(string lang)
{
...
Routing.RegisterRoute(nameof(Dashboard), typeof(Dashboard));
await Shell.Current.GoToAsync($"{nameof(Dashboard)}");// it redirect but with button back
RemoveStackNavigation ()
// await Shell.Current.GoToAsync("//main"); like this , it dosent refresh the page with
Shell.Current.FlyoutIsPresented = false;
}
here is the MVMM
public string _selectedLang;
public string SelectedLang
{
get
{
return _selectedLang;
}
set
{
if (_selectedLang != value)
{
_selectedLang = value;
OnPropertyChanged("SelectedLang");
ChangeBuilding(value);
}
}
}
I tried to RemoveStackNavigation before make redirection to Dashboard like this :
public static void RemoveStackNavigation()
{
var existingPages = Shell.Current.Navigation.NavigationStack.ToList();
foreach (var page in existingPages)
{
if (page != null)
Shell.Current.Navigation.RemovePage(page);
}
}