Manipulating a Storyboard's target object

Posted by slugster on Stack Overflow See other posts from Stack Overflow or by slugster
Published on 2010-03-24T12:39:28Z Indexed on 2010/03/24 12:43 UTC
Read the original article Hit count: 520

In the handler for the Completed event of a Storyboard, how do i get the element that the storyboard was being applied to?

My Storyboard is part of an ItemTemplate:

<ListBox x:Name="MyListBox" >
    <ListBox.ItemTemplate>
        <DataTemplate>
            <Grid x:Name="Container" Height="30" >
                <Grid.Resources>
                    <Storyboard x:Name="FadeOut" BeginTime="0:0:7"  Completed="FadeOut_Completed">
                        <DoubleAnimation From="1.0" To="0.0" Duration="0:0:3" Storyboard.TargetName="Container" Storyboard.TargetProperty="Opacity" />
                    </Storyboard>
                </Grid.Resources>

                [...snip...]

            </Grid>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>

in the Completed event i want to grab the grid called Container so that i can do nasty things with its DataContext. Can this be done, or am i going about it the wrong way?

Thanks :)

© Stack Overflow or respective owner

Related posts about silverlight-3.0

Related posts about animation