I have two windows act as CRUD, both have the same ComboBox
items:
<ComboBox x:Name="LessonTypeNameText" materialDesign:HintAssist.Hint="نوع الدرس و الموضوع" Style="{StaticResource MaterialDesignFloatingHintComboBox}" >
<ComboBoxItem>السنة الأولى: من هدي القرآن الكريم == من دلائل القدرة ( الأنعام: 95 ـ 99).</ComboBoxItem>
<ComboBoxItem>السنة الأولى: من هدي القرآن الكريم == الوصايا العشر ( الأنعام: 151 ـ 152).</ComboBoxItem>
<ComboBoxItem>السنة الأولى: من هدي القرآن الكريم == صفات عباد الرحمن ( الفرقان: 63 ـ 77).</ComboBoxItem>
<ComboBoxItem>السنة الأولى: من هدي القرآن الكريم == الوصايا العشر ( الأنعام: 151 ـ 152).</ComboBoxItem>
</ComboBox>
Now if data pulled from database to fill the first edit window, the ComboBox
select the index based in the value from the database, but the second window it's ComboBox
doesn't select the index.
After some digging I found the comparison is fail in the second window, I tried to see if there a hidden character but there isn't.
private void KafaaOstadiaWindow_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
try
{
_reportDetails = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(_KafaaReport[1]);
}
catch (Newtonsoft.Json.JsonException ee)
{
MessageBox.Show(ee.ToString());
}
//MessageBox.Show(_reportDetails["teacherId"]);
ComboBoxItem comboBoxItem = null;
comboBoxItem = sifaTeacher01ComboBox.Items.OfType<ComboBoxItem>().FirstOrDefault(x => x.Content.ToString() == _reportDetails["sifaTeacher01"].ToString());
sifaTeacher01ComboBox.SelectedIndex = sifaTeacher01ComboBox.Items.IndexOf(comboBoxItem);
schoolTeacher01Text.Text = _reportDetails["schoolTeacher02"];
//MessageBox.Show(_reportDetails["LessonTypeName01"].ToString());
comboBoxItem = LessonTypeNameText.Items.OfType<ComboBoxItem>().FirstOrDefault(x => x.Content.ToString() == _reportDetails["LessonTypeName01"].ToString());
LessonTypeNameText.SelectedIndex = LessonTypeNameText.Items.IndexOf(comboBoxItem);
}
This is the value from the database:
السنة الأولى: من هدي القرآن الكريم == صفات عباد الرحمن ( الفرقان: 63 ـ 77).
The index 2 should be selected but not, all other combo's work fine. What I am missing here?
UPDATE:
If the content is an English or Latin then the ComboBoxItem
get selected, but if I return it back to Arabic then it does not found.