I have a search textbox on silverlight app where user types in search term and results are displayed in textblock, requirement is the search term matches should be highlighted in textblocks.
I have seen some examples of highlighting search terms in textblock but none using mvvm pattern. Im binding text property of textblock in viewmodel, i tried to access inline collection to specify different tags but later came to know that inline collection is not bindable.
<TextBlock Text="{Binding Description}"/>
This description is being set in ViewModel
OK i figured out how to do it in MVVM.
I used a
RadRichTextBoxcontrol from Telerik to achieve the task.I created a new class with dependency property as
bindableXaml& method which converts string to XAML(created newRadRichTextBoxin code to do highlight work in this and returned result asradDocument)RadRichTextBox, so inViewModelthe string from DB is converted into desired XAML format viaStringToXamlmethod. You can achieve the same result usingRichTextBoxbut the XAML created in it will requireStringBuilderandRegEx.Match()to do highlight work.