Changing a border property inside a TreeView.ItemTemplate via Storyboard

334 views Asked by At

So, I have the following code:

<TreeView x:Name="treeUsers">
    <TreeView.ItemTemplate>
        <HierarchicalDataTemplate DataType="wpfTestBench:Group" 
ItemsSource="{Binding myList }">
            <Border x:Name="headerTree" Background="#FFD9D7FD" CornerRadius="3" 
Padding="2" Margin="2">
                <Grid Width="330" Height="20">
                </Grid>
            </Border>
            <HierarchicalDataTemplate.ItemTemplate>
                <DataTemplate DataType="wpfTestBench:User">
                </DataTemplate>
            </HierarchicalDataTemplate.ItemTemplate>
        </HierarchicalDataTemplate>
    </TreeView.ItemTemplate>
    <TreeView.ItemContainerStyle>
        <Style TargetType="{x:Type TreeViewItem}">
            <Setter Property="IsExpanded" Value="{Binding IsExpanded}"></Setter>
        </Style>
    </TreeView.ItemContainerStyle>
</TreeView>

I want to change the backgroud of that border via storyboard, but I'm having no luck in doing so. I've tried using

Storyboard.TargetName=headerTree

But I got an error saying that headerTree couldn't be found.

Edit: Here's my current storyboard:

    <Storyboard x:Key="ChangeColorStoryboard">
                <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="
(Panel.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)"
 Storyboard.TargetName="grid">
                    <EasingColorKeyFrame KeyTime="0:0:0.5" Value="#FFA3DA9A"/>
                </ColorAnimationUsingKeyFrames>
                <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="
(Border.BorderBrush).(GradientBrush.GradientStops)[2].(GradientStop.Color)"
 Storyboard.TargetName="border">
                    <EasingColorKeyFrame KeyTime="0:0:0.5" Value="#FFA3DA9A"/>
                </ColorAnimationUsingKeyFrames>
                <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="
(Border.BorderBrush).(GradientBrush.GradientStops)[1].(GradientStop.Color)"
 Storyboard.TargetName="border">
                    <EasingColorKeyFrame KeyTime="0:0:0.5" Value="#FFA3DA9A"/>
                </ColorAnimationUsingKeyFrames>
            </Storyboard>

PS: The code to change the desired color isn't there, because I have no idea on how to do it.

0

There are 0 answers