locked
Why isn't my viewstatemanger working for pointerover?

    Question

  • I can't seem to get the desired pointer over effect working.

    <Grid Height="50"  x:Name="TextGrid">
    <VisualStateManager.VisualStateGroups>
        <VisualStateGroup x:Name="CommonStates">
            <VisualState x:Name="Normal"/>
            <VisualState x:Name="PointerOver">
                <Storyboard>
                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="TestGrid" Storyboard.TargetProperty="Background">
                        <DiscreteObjectKeyFrame KeyTime="0" Value="Green"/>
                    </ObjectAnimationUsingKeyFrames>
                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="TestGrid" Storyboard.TargetProperty="Foreground">
                        <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource AppBarItemPointerOverBackgroundThemeBrush}"/>
                    </ObjectAnimationUsingKeyFrames>
                </Storyboard>
    
            </VisualState>
        </VisualStateGroup>
    </VisualStateManager.VisualStateGroups>
    <Grid.Transitions>
        <TransitionCollection>
            <EntranceThemeTransition></EntranceThemeTransition>
        </TransitionCollection>
    
    </Grid.Transitions>
    <Grid x:Name="TestGrid" Background="SeaShell">
        <TextBlock Text="test" x:Name="testTextBlock" VerticalAlignment="Center" Foreground="OrangeRed" FontFamily="Calibri" FontSize="20" FontWeight="Light"></TextBlock>
    </Grid>

    Tuesday, March 4, 2014 5:45 PM

Answers

  • What does your code look like to trigger the PointerOver state?

    Is your call to VisualStateManager.GoToState() getting hit?

    --Rob

    Tuesday, March 4, 2014 6:06 PM
    Owner
  • I implemented the pointer over in my control that i uploaded here: http://code.msdn.microsoft.com/windowsapps/AppBar-Hint-control-17e23dbf maybe useful as examlpe for you

    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Tuesday, March 4, 2014 8:55 PM
  • Something needs to trigger the visual state change. The Xaml mark up says what to do when entering the states. The actual trigger needs to come from code-behind.

    If you're templating an existing control (e.g. a Button) then the control will trigger the states that the control defines. Since the Grid doesn't have any such behavior built in (it's not a control itself) you would need to define how it works.

    --Rob

    • Marked as answer by JavierLSU Wednesday, March 5, 2014 3:14 PM
    Tuesday, March 4, 2014 10:34 PM
    Owner

All replies

  • What does your code look like to trigger the PointerOver state?

    Is your call to VisualStateManager.GoToState() getting hit?

    --Rob

    Tuesday, March 4, 2014 6:06 PM
    Owner
  • I implemented the pointer over in my control that i uploaded here: http://code.msdn.microsoft.com/windowsapps/AppBar-Hint-control-17e23dbf maybe useful as examlpe for you

    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Tuesday, March 4, 2014 8:55 PM
  • I was under the impression that this could be done with pure xaml.  I didn't realize I had to handle an event.
    Tuesday, March 4, 2014 9:39 PM
  • Something needs to trigger the visual state change. The Xaml mark up says what to do when entering the states. The actual trigger needs to come from code-behind.

    If you're templating an existing control (e.g. a Button) then the control will trigger the states that the control defines. Since the Grid doesn't have any such behavior built in (it's not a control itself) you would need to define how it works.

    --Rob

    • Marked as answer by JavierLSU Wednesday, March 5, 2014 3:14 PM
    Tuesday, March 4, 2014 10:34 PM
    Owner
  • Thanks, that was exactly what I needed to know.

    I ended up just wrapping the data and using it as a button context, and created a custom button style in blend and made my adjustments there.

    Wednesday, March 5, 2014 3:15 PM