private void TextBlockD_Loaded(object sender, System.Windows.RoutedEventArgs e) { TextBlock curBlock = sender as TextBlock; if (null != curBlock) { string query = App.Current.EntityService.SearchQuery; int index = curBlock.Text.ToLower().IndexOf(query.ToLower()); if (index > -1) { string begin = curBlock.Text.Substring(0, index); string selection = curBlock.Text.Substring(index, query.Length); string end = curBlock.Text.Substring(index + query.Length); curBlock.Inlines.Clear(); curBlock.Inlines.Add(new Run() { Text = begin, Foreground = App.Current.AntiPhoneBackgroundBrush }); curBlock.Inlines.Add(new Run() { Text = selection, Foreground = App.Current.BlueBrush }); curBlock.Inlines.Add(new Run() { Text = end, Foreground = App.Current.AntiPhoneBackgroundBrush }); } DialogsPanel.UpdateLayout(); } }