1

I am currently working in wpf. I was animating the color of textblock control inside the tab item. When the tab is selected, i want to change the foreground to white, i-e

   <ColorAnimation 
        Storyboard.TargetName="buttonText" 
        Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" 
        To="White" Duration="0:0:.1" />

the tab control code is;

 <TabControl Name="tabSteps" Template="{StaticResource OfficeTabControl}">
        <TabItem Header="Info" IsSelected="True">
            <TextBlock>Info content</TextBlock>
            </TabItem>
            <TabItem Header="Recent">
                <TextBlock>Recent content tab</TextBlock>
            </TabItem>
            <TabItem Header="New">
                <TextBlock>New content tab</TextBlock>
            </TabItem>
            <TabItem Header="Print">
                <TextBlock>Print content tab</TextBlock>
            </TabItem>
            <TabItem Header="Save &amp; Send">
                <TextBlock>Save &amp; send content tab</TextBlock>
            </TabItem>
            <TabItem Header="Help">
                <TextBlock>Help tab</TextBlock>
            </TabItem>
        </TabControl>

I want to target the textblock. But it isn't working. Any help will be appreciated. I am following this work http://www.codeproject.com/Articles/155211/Building-a-control-template-style-for-the-tabContr.aspx

Idrees Khan
  • 7,702
  • 18
  • 63
  • 111

1 Answers1

0

Using the VisualStateManager, create a state for when your TabItem is selected. You can then specify the animation you mentioned to start as a transition to and from the selected state (see http://blogs.intuidev.com/post/2010/01/26/TabControlStyling_PartTwo.aspx for a tutorial).

The default style for the TabControl is here (http://msdn.microsoft.com/en-us/library/cc645035(v=vs.95).aspx), or you can easily generate it if you use Expression Blend.

You could also use this approach (a programmatic trigger) : https://stackoverflow.com/a/4958562/914602

Community
  • 1
  • 1
Marcel
  • 944
  • 2
  • 9
  • 29