作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我在我的 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/
我在我的 C#/XAML WinRT 应用程序中使用托管在服务器上的图像。下载该图像后,我希望它淡入。我注意到 FadeInThemeAnimation,这是我希望使用的。但是,我想像 Entranc
我的 XAML 中有一个包含 ProgressRing 的网格,当应用程序执行长时间运行的任务时,它会淡入 View :
我是一名优秀的程序员,十分优秀!