Reputation: 3083
I have created a Win Phone 8.1 project showing a ListView where each item is displayed in a simple TextBlock. Just as in the first HubSection when you create a new project using the Hub App template under Store Apps -> Windows Phone Apps.
<HubSection x:Uid="HubSection1" Header="My Data">
<DataTemplate>
<ListView
ItemsSource="{Binding CollectionOfData}">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,0,16">
<TextBlock Text="{Binding MyDataProperty}" Style="{ThemeResource ListViewItemTextBlockStyle}" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</DataTemplate>
</HubSection>
Now I am trying to figure out how I can change the style of the text in the selected ListViewItem TextBlock. That is I want the text to be set to bold for the selected item. I think I have done something similar using triggers previously.
Upvotes: 0
Views: 313
Reputation: 1927
You can edit ItemStyleContainer, then find VisualState x:Name="Selected"
and change to this:
<VisualState x:Name="Selected">
<Storyboard>
<DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="CheckGlyph"/>
<DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="SelectedCheckMark"/>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="contentPresenter">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<SolidColorBrush Color="Red"/>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
You can change <SolidColorBrush Color="Red"/>
from red to your desire color
Upvotes: 0
Reputation: 33
I think you can achieve this with Microsoft.Xaml.Interactivity
and HTML tags. Check this blog article: Displaying HTML content in a TextBlock. I have a fixed code for binding and styling, tell me if you will need it.
Upvotes: 0