views:

57

answers:

1

I have some trigger in my Windows Phone 7 Silverlight app such as

<Grid x:Name="ContentGrid" Grid.Row="1" Background="Red" Height="100">
    <Grid.Triggers>
        <EventTrigger RoutedEvent="Loaded">
            <BeginStoryboard>
                <Storyboard>
                    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="Opacity">
                        <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                        <SplineDoubleKeyFrame KeyTime="00:00:10" Value="1"/>
                    </DoubleAnimationUsingKeyFrames>
                </Storyboard>
            </BeginStoryboard>
        </EventTrigger>
    </Grid.Triggers>
</Grid>

But when Loaded event fires, XamlParseException occurs. I googled a bit, but found nothing.

Any idea to find solution? Thanks.

+4  A: 

I changed your code a bit:

  • Changed the RoutedEvent to Grid.Loaded
  • Added the TargetName with a reference to the Grid
  • Change the TargetProperty to Grid.Opacity

view the code below:

<Grid x:Name="ContentGrid" Grid.Row="1" Background="Red" Height="100">
        <Grid.Triggers>
            <EventTrigger RoutedEvent="Grid.Loaded">
                <BeginStoryboard>
                    <Storyboard>
                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"  Storyboard.TargetName="ContentGrid" Storyboard.TargetProperty="Grid.Opacity">
                            <SplineDoubleKeyFrame KeyTim>
                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:10" Value="1"/>
                        </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger>
        </Grid.Triggers>
</Grid>
Wouter Janssens - Xelos bvba
thank, works fine :)
Vitali Fokin