The following definition is used as ItemContainer
style for a GridView
, SelectionMode
"Single". When an element is selected, a particular glyph becomes visible to indicate selection.
It works right with Windows 8.1, but with UWP, it accepts changed state: Selected makes the glyph to appear, but does not revert to the original state (state Unselected), glyph stays with selection changed, even though SelectionChanged
event brings the old selection as removed item.
Similar problems exist for other states (like Pressed and Focused), I just don't show the full VisualStateManager for simplicity.
<Style x:Key="MyItemContainerStyle" TargetType="SelectorItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="SelectorItem">
<Border>
<Grid>
<!-- Layout of the grid -->
</Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="SelectionStates">
<VisualState x:Name="Unselected" />
<VisualState x:Name="SelectedUnfocused">
<Storyboard>
<DoubleAnimation Storyboard.TargetName="SelectingGlyph"
Storyboard.TargetProperty="Opacity"
To="1"
Duration="0" />
</Storyboard>
</VisualState>
<VisualState x:Name="Selected">
<Storyboard>
<DoubleAnimation Storyboard.TargetName="SelectingGlyph"
Storyboard.TargetProperty="Opacity"
To="1"
Duration="0" />
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Tried also
<VisualState x:Name="Unselected">
<Storyboard>
<DoubleAnimation Storyboard.TargetName="SelectingGlyph"
Storyboard.TargetProperty="Opacity"
To="0"
Duration="0" />
</Storyboard>
</VisualState>
But didn't help.