title: GridView's ItemContainerStyle and selection states
body: <p>I'm trying to change the appearance of gridview items when they are selected.
  (Before, I used a trick with an IsSelected property in the ViewModel object bound to the containing grid and a bool-to-color converter, but I recognize that it is bad)</p>
  
  <p>To do so, I do:</p>
  
  <pre class="lang-xml prettyprint-override"><code>    &lt;GridView ItemContainerStyle="{StaticResource GridViewItemContainerStyle}" ...&gt; ...
  </code></pre>
  
  <p>and</p>
  
  <pre class="lang-xml prettyprint-override"><code>    &lt;Style x:Key="GridViewItemContainerStyle" TargetType="GridViewItem"&gt;
          &lt;Setter Property="Background" Value="Red" /&gt;
          &lt;Setter Property="Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate TargetType="GridViewItem"&gt;
                      &lt;Grid&gt;
                          &lt;VisualStateManager.VisualStateGroups&gt;
                              &lt;VisualStateGroup x:Name="CommonStates"&gt;
                                  &lt;VisualState x:Name="Normal"&gt;
                                      &lt;Storyboard&gt;
                                          &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Grid.Background)" Storyboard.TargetName="itemGrid"&gt;
                                              &lt;DiscreteObjectKeyFrame KeyTime="0" Value="Black"/&gt;
                                          &lt;/ObjectAnimationUsingKeyFrames&gt;
                                      &lt;/Storyboard&gt;
                                  &lt;/VisualState&gt;
                              &lt;/VisualStateGroup&gt;
                              &lt;VisualStateGroup x:Name="SelectionStates"&gt;
                                  &lt;VisualState x:Name="UnselectedSwiping"/&gt;
                                  &lt;VisualState x:Name="UnselectedPointerOver"/&gt;
                                  &lt;VisualState x:Name="Selecting"/&gt;
                                  &lt;VisualState x:Name="Selected"&gt;
                                      &lt;Storyboard&gt;
                                          &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Grid.Background)" Storyboard.TargetName="itemGrid"&gt;
                                              &lt;DiscreteObjectKeyFrame KeyTime="0" Value="White"/&gt;
                                          &lt;/ObjectAnimationUsingKeyFrames&gt;
                                      &lt;/Storyboard&gt;
                                  &lt;/VisualState&gt;
                                  &lt;VisualState x:Name="SelectedSwiping"/&gt;
                                  &lt;VisualState x:Name="Unselecting"/&gt;
                                  &lt;VisualState x:Name="Unselected"/&gt;
                                  &lt;VisualState x:Name="SelectedUnfocused"/&gt;
                              &lt;/VisualStateGroup&gt;
                          &lt;/VisualStateManager.VisualStateGroups&gt;
  
                          &lt;Grid ... x:Name="itemGrid"&gt;
                                &lt;!-- HERE MY DATA TEMPLATE --&gt;
                          &lt;/Grid&gt;
                      &lt;/Grid&gt;
                  &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
      &lt;/Style&gt;
  </code></pre>
  
  <p>When I run the app, the items are Black (as in the "normal" state). But selecting them does not turn them into White. Where am I wrong?</p>
  
  <p>Moreover, it there a way to set "ItemContainerStyle" without having it to "overwrite" the "ItemTemplate" ???</p>