0
votes

I need to change the StackPanel background color for the item selected by user.

Apprecaite your help.

here my XAML:


<DataTemplate x:Key="SpeechTemplate">

 <StackPanel x:Name="Sp" Width="400" Height="120" Background="Red">

    <TextBlock Text="{Binding Title}" 
                     Grid.Column="0"
                     Margin="3,3,0,0" 
                     TextWrapping="Wrap"
                     VerticalAlignment="Top"
                     FontSize="24"
                     FontWeight="SemiBold"/>

    <TextBlock Text="{Binding SId}" 
                     Grid.Column="1"
                     Margin="3,3,0,0" 
                     TextWrapping="Wrap"
                     VerticalAlignment="Top"
                     FontSize="18"/>

   <TextBlock Text="{Binding TopicId}" 
                      Grid.Column="2"
                      Margin="3,3,0,0" 
                      TextWrapping="Wrap"
                      VerticalAlignment="Top"
                      FontSize="18"/>

   </StackPanel>

 </DataTemplate>




<ListView x:Name="SpeechesGridView" Width="420"                               
                  Foreground="White"     
                  SelectionMode="None"
                  IsSwipeEnabled="True"
                  IsItemClickEnabled="True"

      ItemsSource="{Binding Mode=OneWay, Source={StaticResource SpeechesViewSource}}"                      
      ItemTemplate="{StaticResource SpeechTemplate}"

      ItemClick="SpeechesGridView_ItemClick"      

      SelectionChanged="SpeechesGridView_SelectionChanged"/>




1

1 Answers

0
votes

Override/add <SolidColorBrush x:Key="ListViewItemSelectedBackgroundThemeBrush" Color="#YourColor" /> to your Application.Resources. You'll find all default colours in the generic.xaml file here: C:\Program Files (x86)\Windows Kits\8.1\Include\winrt\xaml\design (Assuming you work with x64).