我正在尝试使 WPF 中的图像控件在加载源时进行动画处理。
我已经找到了一个解决方案,但它是为 Windows 8 Metro 开发准备的,其中包含 ImageOpened
事件,这个事件在普通的 WPF 图像控件中并不存在。
你知道如何让图像在加载时显示加载动画的解决方案吗?
也许有一些带有这种类型的图像控件的库?
这是我在 Win 8 dev 中找到的 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;
}
BitmapSource.DownloadCompleted
事件。 - dkozl