簡體   English   中英

在ListView中指定VisualStateGroups

[英]Specifying VisualStateGroups in a ListView

我正在嘗試重新定義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>

我的問題是,當我將光標放在所選項目上時,即使我不想這樣做,背景也會改變。 當我搬出時,該項目將獲得“正常”背景,而不是保持“選定”背景。

如何指定所選項目的背景一定不能改變?

編輯:我仍然想對未選中的項目產生過度影響。

您需要從PointerOver狀態中刪除情節提要。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM