事件触发器不起作用

发布于 2024-09-15 01:26:21 字数 878 浏览 2 评论 0原文

我的 Windows Phone 7 Silverlight 应用程序中有一些触发器,例如

<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>

但当 Loaded 事件触发时,会发生 XamlParseException。 我用谷歌搜索了一下,但什么也没找到。

有想法找到解决方案吗? 谢谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼波传意 2024-09-22 01:26:21

我稍微更改了您的代码:

  • 将 RoutedEvent 更改为 Grid.Loaded
  • 添加了 TargetName 并引用了网格
  • 将 TargetProperty 更改为 Grid.Opacity

查看下面的代码:

<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>

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文