I have a list of phrases which needs to be displayed. These phrases have a static text and a variable number of bits that need to be highlighted on the screen (bold, colored differently).
Here's a sample of how this would look like if I am to build everything from xaml.
<TextBlock Grid.Row="2">
<Run Text="Your"/>
<Run Text="{Binding Text1}"/>
<Run Text="has a limit of $"/>
<Run Text="{Binding Limit}" FontWeight="Bold" Foreground="Red"/>
<Run Text="for period "/>
<Run Text="{Binding StartDate}" FontWeight="Bold" Foreground="Blue"/>
<Run Text=" : "/>
<Run Text="{Binding EndDate}" FontWeight="Bold" Foreground="Blue"/>
<Run Text=". Your up to date expenses are $"/>
<Run Text="{Binding Expenses}" FontWeight="Bold" Foreground="Red"/>
</TextBlock>
<TextBlock Grid.Row="3">
<Run Text="Your"/>
<Run Text="{Binding Text2}"/>
<Run Text="has a limit of $"/>
<Run Text="{Binding Limit2}" FontWeight="Bold" Foreground="Red"/>
<Run Text="for period "/>
</TextBlock>
What I would like to achieve is to somehow bind the text with {0} in it and an bind an ItemsSource that will set the Inlines for a TextBlock, and further, bind an ItemsSource maybe for styles (font weight and text color) each inline should have:
Text: Your {0} has a limit of ${1} for period.
Values to populate inlines: abc,1000
Styles to apply {none,none}, {bold,red}
Is this possible in the first place? And if so, can you please point me in the right direction or give me a few hints?
Thanks.
ItemsControlbound to list of parts whereItemsPanelis horizontalStackPanel(for example) andItemTemplateisTextBlock