Real World
Real World

Reputation: 1719

Windows Store App ListView item databinding and visual states

I can't find the way to handle this situation. I have a ListView in my Windows 8 store app. The list is databound and has an ItemTemplate like follows.

<DataTemplate x:Key="FixtureItem">
            <Grid Height="110" Margin="6" Width="521" Background="#7F335107">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="110"/>
                    <ColumnDefinition/>
                    <ColumnDefinition Width="110"/>
                </Grid.ColumnDefinitions>
                <TextBlock x:Name="awayTeamScore" Text="{Binding AwayTeamScore}" Style="{StaticResource TitleTextStyle}" TextWrapping="NoWrap" Margin="5,0,5,11" FontSize="22" FontWeight="Bold" Grid.Column="1" FlowDirection="RightToLeft" VerticalAlignment="Bottom" FontStretch="Condensed" />
                <TextBlock x:Name="matchInfo" Text="{Binding MatchInfo}" Style="{StaticResource TitleTextStyle}" TextWrapping="NoWrap" Margin="10,40,10,50" FontSize="22" FontWeight="Bold" Grid.Column="1" FlowDirection="RightToLeft" TextAlignment="Center"/>
                <TextBlock x:Name="homeTeamScore" Text="{Binding HomeTeamScore}" Style="{StaticResource TitleTextStyle}" TextWrapping="NoWrap" Margin="5,6,5,0" FontSize="22" FontWeight="Bold" Grid.Column="1" Height="20" VerticalAlignment="Top" FontStretch="Condensed" />
                <Image x:Name="homeTeamImage" Source="{Binding HomeImage}" Stretch="Uniform" AutomationProperties.Name="{Binding HomeTeam}" Width="110"/>
                <Image x:Name="awayTeamImage" Source="{Binding AwayImage}" Stretch="Uniform" AutomationProperties.Name="{Binding AwayTeam}" Grid.Column="2"/>
            </Grid>
        </DataTemplate>

The problem i have is that Windows 8 has a little animation when you click an item in the list view. This happens even if the list is set to SelectionMode="none". I therefore need to change the visual state of the pressed state to

<VisualState x:Name="Pressed"/>

But I can't seem to get this to work inside my data template. What is the correct way to do this without breaking the databinding?

Upvotes: 1

Views: 774

Answers (1)

Michał Żołnieruk
Michał Żołnieruk

Reputation: 2105

If you just don't want any selection, why won't you consider using ItemsControl instead of a ListView? You have to keep in mind that virtualization is not implemented there though, look here for details.

Upvotes: 1

Related Questions