- Jan 10, 2012
- 155
- 1
- 0
My app parses XML data and displays it nicely with DataTemplate and embedded TextBlock. I have found ways to format the TextBlock with <Run> tags, but it doesn't appear to possible to add those at run-time. Here is my code:
The text for the verses are displayed like this:
1 In the beginning ...
I create a List<string> in my code that builds each chapter into this format and displays it.
Essentially, I want just the verse number in bold, and the rest of the text in normal weight. I have seen examples that were non-specific to WP7, using WPF, but I am not sure if importing those libraries will work correctly on a WP device.
Any suggestions?
Code:
<ListBox HorizontalAlignment="Left" Margin="-12,-40,0,0" Name="verses" Width="480" Height="620" SelectionChanged="enableSharing">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Name="verseBlock" Text="{Binding}" TextWrapping="Wrap" Width="15" HorizontalAlignment="Stretch"
DataContext="{Binding}" Tag="{Binding}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ListBox>
The text for the verses are displayed like this:
1 In the beginning ...
I create a List<string> in my code that builds each chapter into this format and displays it.
Essentially, I want just the verse number in bold, and the rest of the text in normal weight. I have seen examples that were non-specific to WP7, using WPF, but I am not sure if importing those libraries will work correctly on a WP device.
Any suggestions?