gpt4 book ai didi

c# - 在 WinRT 中使用 FadeInThemeAnimation 作为过渡

转载 作者:太空狗 更新时间:2023-10-29 20:03:19 25 4
gpt4 key购买 nike

我在我的 C#/XAML WinRT 应用程序中使用托管在服务器上的图像。下载该图像后,我希望它淡入。我注意到 FadeInThemeAnimation,这是我希望使用的。但是,我想像 EntranceThemeTransition 一样使用它。有没有办法做到这一点?如果是,怎么办?

最佳答案

我遇到了同样的问题,但找到了解决方案,我认为分享它可能仍然有用。

显然 FadeInThemeAnimation 是一种特殊的动画,它不像您想象的那样作用于 Opacity 和 Visibility,而是作用于项目的 RenderTransform。我只是在使用 FadeOutThemeAnimation 淡出项目时才设法让它工作。

但这里有一个解决方法。在您的 XAML 中,将 Storyboard添加到图像容器的资源中,如下所示:

<Grid>
<Grid.Resources>
<Storyboard x:Name="ImageFadeInStoryboard">
<DoubleAnimation From="0" To="1" Storyboard.TargetName="yourImage" Storyboard.TargetProperty="Opacity" Duration="0:0:0.6" />
</Storyboard>
</Grid.Resources>
<Image x:Name="yourImage" Source="{Binding ...}"/>
...

然后向图像的 ImageOpened 事件添加处理程序:

<Image x:Name="yourImage" Source="{Binding ...}" ImageOpened="OnImageOpened"/>

在代码隐藏中:

private void OnImageOpened(object sender, RoutedEventArgs e)
{
ImageFadeInStoryboard.Begin();
}

希望对您有所帮助:)

关于c# - 在 WinRT 中使用 FadeInThemeAnimation 作为过渡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11273734/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com