C# 带加载动画的WPF图像
我正试图使WPF中的图像控件在加载源代码时具有动画效果 我找到了一个为Windows8 Metro开发准备的解决方案,它包含C# 带加载动画的WPF图像,c#,wpf,xaml,C#,Wpf,Xaml,我正试图使WPF中的图像控件在加载源代码时具有动画效果 我找到了一个为Windows8 Metro开发准备的解决方案,它包含ImageOpened事件,这在正常的WPF图像控件中是不存在的 您知道在加载时制作图像显示加载动画的任何解决方案吗 也许有一些库具有这种图像控制 下面是我为Win 8开发人员找到的ImageLoader控件: <Grid> <Image x:Name="imgDisplay" Source="{Binding ElementName=parent
ImageOpened
事件,这在正常的WPF图像控件中是不存在的
您知道在加载时制作图像显示加载动画的任何解决方案吗
也许有一些库具有这种图像控制
下面是我为Win 8开发人员找到的ImageLoader控件:
<Grid>
<Image x:Name="imgDisplay" Source="{Binding ElementName=parent,Path=Source}"
ImageFailed="OnImageFailed"
ImageOpened="OnImageOpened" />
<ContentControl
Visibility="{Binding ElementName=parent,Path=IsLoading,Converter={StaticResource converter}}"
Content="{Binding ElementName=parent,Path=LoadingContent}"
VerticalContentAlignment="Stretch"
HorizontalContentAlignment="Stretch" />
<ContentControl Visibility="{Binding ElementName=parent,Path=IsFailed,Converter={StaticResource converter}}"
Content="{Binding ElementName=parent,Path=FailedContent}"
VerticalContentAlignment="Stretch"
HorizontalContentAlignment="Stretch" />
</Grid>
模拟解决方案:将
图像
控件放置在显示加载动画的控件顶部(例如,将两者放在同一网格
)。只要图像没有完全加载,它就是透明的,让加载的动画通过,加载完成后,它会自动隐藏动画。如果源代码是位图源代码,您可以尝试使用事件
void OnImageOpened(object sender, RoutedEventArgs e)
{
this.IsLoading = false;
this.IsLoaded = true;
}