UWP alterar o idioma CalendarDatePicker em tempo de execução
Eu tenho um aplicativo que altera a interface do usuário em tempo de execução. Aqui está o meu código para alterar o idioma:
public void SwitchLanguage(SupportedLanguage language)
{
// Check if passed argument is different from current language
if (CurrentLanguage != language.Type)
{
// Set the new current language
CurrentLanguage = language.Type;
// Override tha application primary language ( it will automatically save the language preference )
Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = language.FourDigitCode;
ResourceContext.GetForViewIndependentUse().Reset();
ResourceContext.GetForCurrentView();
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("LocalizedResourceMap"));
// Notify code about the changes
this.LanguageChanged?.Invoke(this, new EventArgs());
}
}
Toda a localização funciona bem, exceto CalendarDatePicker - o Flyout não é localizado (em tempo de execução, quando eu reinicio o aplicativo - tudo se bem).
Aqui estão os exemplos
Abriu uma página e selecionou CalendarDatePicker:
Mudou o idioma para o russo:
Eu tentei fazer isso:
// Attach to LanguageChanged event - created in my own code
// And trigger this method inside CalendarDatePicker:
private void LanguageChanged(object sender, EventArgs e)
{
this.Language = "ru-RU"; // Hardcoded value for test only
}
E o resultado é este:
Eu também tentei invalidar () tudo. Também tentei acionar o método TemplateChild CalendarView Update - sem uso. Alguma sugestão de como conseguir uma mudança normal de idioma?
EDITAR:
Graças a Elvis Xia, notamos que, na alteração de idioma no código, o tamanho do CalendarView é ferrado, porque se eu fizer isso:
this.calendar.Language = "ru-RU"
this.calendar.Height = 500;
this.calendar.Width = 500;
Vou ver as datas (ferrado, mas ainda assim):
Alguma idéia de como corrigir isso?