locked
Template Binding in Storyboard RRS feed

  • Question

  • Hello

    I want to change foreground of a AppBarButton so I just bind the AppBarButtonStyle's Pointer over Style to Button's Foreground but it won't work why?

     <VisualState x:Name="PointerOver">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGlyph" Storyboard.TargetProperty="Foreground">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource AppBarItemPointerOverBackgroundThemeBrush}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Content" Storyboard.TargetProperty="Foreground">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{TemplateBinding Foreground}"/>
                                            </ObjectAnimationUsingKeyFrames>
    </Storyboard>
    </VisualState>


    Santana George

    Thursday, October 17, 2013 7:41 AM

All replies

  • Hi Santana - I don't really understand your question.  Can you please explain a bit more, and may post a working sample?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Friday, October 18, 2013 1:05 PM
    Moderator
  • http://sdrv.ms/16XWHOG

    working sample is in above link please download it

    I have two AppBar buttons in mainpage  style of each button are same which is in Common/MyStyles.xaml. i need to show two different colors(foreground) when I point to each buttons so I just Template Binded to its foreground in PointerOver state but it don't working.

     <VisualState x:Name="PointerOver">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGlyph" Storyboard.TargetProperty="Foreground">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PointerOverBrush}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Content" Storyboard.TargetProperty="Foreground">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{TemplateBinding Foreground}"/>
                                            </ObjectAnimationUsingKeyFrames>
    </Storyboard>
    </VisualState

    check second ObjectAnimationUsingKeyFrames in PointerOver VisualState

    when pointer over I need to show first button green and second button red I have more than 20 buttons with differnet colors so I don't want to use saved static resources so I decided to bind foreground to buttons foreground but it not working why?


    Santana George

    Saturday, October 19, 2013 4:03 PM