Im trying to set Language for System.Windows.Control.RichTextBox as "es-PE", but I found
some issues, for example in some computers, works perfectly and SpellChecker is enabled
with "es-PE" language, but in others it just works with "en-US", so I Dont know whats the matter with
that control, I was using the following code in XAML and C# :
this is code when users select row from GridView and then shows the screenshot attached
private void dlstInformes_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
if (!dlstInformes.SelectedItem.ToString().Equals(""))
{
var source_ = dlstInformes.SelectedItems;
InformeMedico demo = new InformeMedico(); //New Window
foreach (informeMedico item in source_)
{
numeroinforme = item.numeroinforme.ToString();
nombreinforme = item.nombreinforme;
fechainforme = item.fechainforme.ToString();
nombreMedico = item.medicoCompleto.ToString();
turnoMedico = item.turno.ToString();
nombrePaciente = item.pacienteCompleto.ToString();
nombreExamen = item.nombreinforme.ToString();
}
demo.Language = XmlLanguage.GetLanguage("es-PE");
demo.txtNombreExamen.Text = nombreinforme;
demo.lblNroInforme.Content = numeroinforme;
demo.lblMedicoNombre.Content = nombreMedico;
demo.lblNombrePac.Content = nombrePaciente;
demo.lblTurnoMedico.Content = turnoMedico;
using (DB db = new DB())
{
var lstTM = (from ea in db.EXAMENXATENCIONs where ea.turnomedico.Trim() != " " select ea.turnomedico).Distinct().ToList();
string tm = (from ea in db.EXAMENXATENCIONs where ea.codigo == Convert.ToInt32(numeroinforme) select ea.turnomedico).FirstOrDefault();
demo.cboTurnoMed.ItemsSource = lstTM;
demo.cboTurnoMed.SelectedItem = tm;
demo.cboTurnoMed.SelectedValue = tm;
demo.cboTurnoMed.Text = tm;
if (tm.Equals("RE/ES") || tm.Equals("RE/HS") || tm.Equals("RE/HT") || tm.Equals("RE/KV") || tm.Equals("HH/CS") || tm.Equals("HH/ES") || tm.Equals("HH/HS") || tm.Equals("HH/HT") || tm.Equals("HH/KV"))
{
demo.FirmaUnoDefault.Content = "DEN51";
demo.FirmaDosDefault.Content = tm;
}
else if (tm.Equals("HH/AO") || tm.Equals("IU/AO") || tm.Equals("RE/AO") || tm.Equals("HH/JA") || tm.Equals("RR/JA") || tm.Equals("IU/JA"))
{
demo.FirmaUnoDefault.Content = "DEN51";
demo.FirmaDosDefault.Content = "AOY20";
}
else if (tm.Equals("IU/CS") || tm.Equals("IU/ES") || tm.Equals("IU/HT") || tm.Equals("IU/KV"))
{
demo.FirmaUnoDefault.Content = "IUU17";
demo.FirmaDosDefault.Content = tm;
}
else if (tm.Equals("RD/DE"))
{
demo.FirmaUnoDefault.Content = "REE";
demo.FirmaDosDefault.Content = "DEN51";
}
else if (tm.Equals("RE/JC"))
{
demo.FirmaUnoDefault.Content = "REE";
demo.FirmaDosDefault.Content = "JCCH25";
}
else if (tm.Equals("RE/CS"))
{
demo.FirmaUnoDefault.Content = "DEN51";
demo.FirmaDosDefault.Content = "REE";
}
}
demo.lblCodigoClase.Visibility = Visibility.Hidden;
demo.lblCodigoEstudio.Visibility = Visibility.Hidden;
demo.lblCodigoPaciente.Visibility = Visibility.Hidden;
demo.FirmaUnoDefault.Visibility = Visibility.Hidden;
demo.FirmaDosDefault.Visibility = Visibility.Hidden;
demo.rtbHallazgo.Language = XmlLanguage.GetLanguage("es-PE");
demo.rtbConclusion.Language = XmlLanguage.GetLanguage("es-PE");
demo.rtbTecnica.Language = XmlLanguage.GetLanguage("es-PE");
demo.rtbHallazgo.SpellCheck.IsEnabled = true;
demo.rtbTecnica.SpellCheck.IsEnabled = true;
demo.rtbConclusion.SpellCheck.IsEnabled = true;
demo.rtbConclusion.SpellCheck.SpellingReform = SpellingReform.PreAndPostreform;
demo.ResizeMode = ResizeMode.NoResize;
demo.Closing += new System.ComponentModel.CancelEventHandler(notClosing_CancelEventArgs);
demo.ShowDialog();
}
else
{
MessageBox.Show("Seleccione un item", "Error", MessageBoxButton.OK, MessageBoxImage.Asterisk);
}
}
I also trying configurate and removing "en-US" language from SO, when it happens spellchecker stop completly and when I Re-Add that language for keyboard, it SpellChecker reappears.
Stills not working with "es-PE" or just Spanish as Parent
Thanks in Advance!
I'm not sure if this will help, but it might be worth a shot.
In the Application.StartUp event add the following code
FrameworkElement.LanguageProperty.OverrideMetadata(
typeof(FrameworkElement),
new FrameworkPropertyMetadata(
XmlLanguage.GetLanguage(
CultureInfo.CurrentCulture.IetfLanguageTag)));
Or you can modify it to specify es-PE instead of the current culture.
This post might provide more in-depth details: Getting a WPF application to pick up the correct regional settings