2015-04-18 64 views
2

我試圖使圖像控制在WPF同時加載源動畫。WPF圖像的加載動畫

我已經找到了解決方案,BU爲Windows 8地鐵的發展準備,它包含ImageOpened事件,不正常WPF Image控件存在。

你知道製作圖像顯示加載動畫加載時的任何解決方案?

也許有一些圖書館與那種圖像控制的?

下面是ImageLoader的控制,我發現爲Win 8開發:

<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; 
} 
+1

如果你的'Source'是'BitmapSource',你可以試試['BitmapSource.DownloadCompleted'](https://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapsource。 downloadcompleted(v = vs.110).aspx)事件 – dkozl

回答

1

笑着解決方案:在控制該顯示器的頂部Image控制位置加載動畫(例如,將兩者放在同一個Grid之內)。只要圖像尚未完全載入它的透明,從而使加載動畫彪炳,它已加載完成後,它會自動隱藏動畫。