0

我正在尝试重新定义 ListView(Metro 风格的应用程序)的选定项目的外观。

VisualStateGroups我通过在我的模板中定义来实现它。

<VisualStateManager.VisualStateGroups>
    <VisualStateGroup x:Name="CommonStates">
        <VisualState x:Name="Normal" />
        <VisualState x:Name="PointerOver">
            <Storyboard>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="expenseItem" Storyboard.TargetProperty="Background">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="LightGray"/>
                </ObjectAnimationUsingKeyFrames>
            </Storyboard>
        </VisualState>
    </VisualStateGroup>

    <VisualStateGroup x:Name="SelectionStates">
        <VisualState x:Name="Unselected" />
        <VisualState x:Name="Selected">
            <Storyboard>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemLocationName" Storyboard.TargetProperty="Foreground">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ExpenseListHighlightedText}"/>
                </ObjectAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="expenseItem" Storyboard.TargetProperty="Background">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ApplicationGradientBlue}"/>
                </ObjectAnimationUsingKeyFrames>
            </Storyboard>
        </VisualState>
    </VisualStateGroup>
</VisualStateManager.VisualStateGroups>

我的问题是,当我将光标放在所选项目上时,即使我不希望这样,背景也会发生变化。当我搬出时,该项目将获得“正常”背景,而不是保持“选定”背景。

如何指定所选项目的背景不得更改?

编辑:我仍然希望对未选择的项目产生过度影响。

4

1 回答 1

3

您需要从 PointerOver 状态中删除情节提要。

于 2012-05-07T16:39:18.460 回答