0

我有这个 XAML 视图。VisualStateGroups视觉触发器的 工作正常,但常见VisualStateGroup状态的 不能。

我尝试在开始时分配给一个矩形,然后都不起作用。在其他视图中,这很好用.. :(

<view:NavigationStoredPage.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/Styles/ResponsiveStyles.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</view:NavigationStoredPage.Resources>
    <Grid>
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="CommonStates">
                <VisualState x:Name="Normal"/>
                <VisualState x:Name="PointerOver">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Fill" Storyboard.TargetName="rer">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="#121212"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="MouseOver">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Fill" Storyboard.TargetName="rer">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="#121212"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups> 
        <Rectangle Fill="Red" x:Name="rer" Width="100" Height="100" HorizontalAlignment="Left" Canvas.ZIndex="99" VerticalAlignment="Top" />
4

1 回答 1

1

CommonStates您的代码实际上必须使用状态转换到其中之一VisualStateManager.GoToState()。对于控件,它会自动发生,因为在类或其基类Button中的某处- 调用.ButtonGoToState()

于 2016-03-28T23:13:01.403 回答