I am downloading an xml file and saving it to the phone (Windows Phone 8 app), then I open it as a list. This list has greek words in it with upper, lower and special characters. I want the user to be able to search thru this list without making him write the same text as is in the list, so, so far I made the search bar and the list to turn into Upper characters so if the user types "to" the list highlights "to","To","TO" erasing temporarily the words not matching bringing up the ones matching. But if the user tries to write a letter without intonation the words in the list that have intonation will all be erased until the user presses backspace and type the letter with intonation.
example: list got 2 words. Σπύρος , Μάρα. User presses letter 'Μ', in the list, Σπύρος disappears and Μάρα becomes Μάρα. Now the user types 'α' and Mάρα disappears as well because he had to type 'ά'. If he had it would be Μάρα and so on.
So my question is, is it possible to replace a character with intonation to the same character without intonation? For example. ά to a, Ά to A, etc. On the Unicode character table they have different codes.
The code so far:
private void businessFilterString_TextChanged(object sender, TextChangedEventArgs e)
{
sI.ItemsSource = businesses.Collection.Where(b => b.name.ToUpper().Contains(searchBox.Text.ToUpper()) || b.address.ToUpper().Contains(searchBox.Text.ToUpper())).ToList();
LayoutUpdateFlag = true;
}
private void sI_LayoutUpdated(object sender, EventArgs e)
{
if (LayoutUpdateFlag)
{
SearchVisualTree(sI);
}
LayoutUpdateFlag = false;
}
private void SearchVisualTree(DependencyObject targetElement)
{
var count = VisualTreeHelper.GetChildrenCount(targetElement);
for (int i = 0; i < count; i++)
{
var child = VisualTreeHelper.GetChild(targetElement, i);
if (child is TextBlock)
{
textBlock1 = (TextBlock)child;
prevText = textBlock1.Text.ToUpper();
HighlightText();
}
else
{
SearchVisualTree(child);
}
}
}
private void HighlightText()
{
if (textBlock1 != null)
{
string text = textBlock1.Text.ToUpper();
textBlock1.Text = text;
textBlock1.Inlines.Clear();
int index = text.IndexOf(searchBox.Text.ToUpper());
int lenth = searchBox.Text.Length;
if (!(index < 0))
{
Run run = new Run() { Text = text.Substring(index, lenth), FontWeight = FontWeights.ExtraBold};
run.Foreground = new SolidColorBrush(Colors.Orange);
textBlock1.Inlines.Add(new Run() { Text = text.Substring(0, index), FontWeight = FontWeights.Normal});
textBlock1.Inlines.Add(run);
textBlock1.Inlines.Add(new Run() { Text = text.Substring(index + lenth), FontWeight = FontWeights.Normal });
}
else
{
//textBlock1.Text = "No Match";
}
}
}