2014-04-11 214 views
1

我有一個形象的控制在我的主頁,代碼如下:顯示進度條

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> 
    <StackPanel HorizontalAlignment="Left" Height="597" VerticalAlignment="Top" Width="440"> 
     <Image x:Name="hinh1" Height="488" Stretch="Fill"/> 
     <ProgressBar Name="loading" Height="10" IsIndeterminate="True" Visibility="Collapsed"/> 
    </StackPanel> 
</Grid> 

,並在後面的代碼我有這樣的代碼:

Uri hinh = new Uri 
      ("http://taigamejar.net/wp-content/uploads/2014/01/Hinh-Anh-Dep-5.jpg", UriKind.Absolute); 
     hinh1.Source = new BitmapImage(hinh); 

在等待圖像加載,我想調用進度條運行通知用戶,它正在加載。一旦圖像加載完成,進度條應該消失。我怎樣才能做到這一點?

+0

這隻有一個圖像。如何處理很多圖片 – user3506135

回答

3

如果我是你,我寧願使用,而不是ProgressBar。

所以,我給

protected override void OnNavigatedTo(NavigationEventArgs e) 
{ 
    loading.IsActive = true; 
    Uri hinh = new Uri 
    ("http://taigamejar.net/wp-content/uploads/2014/01/Hinh-Anh-Dep-5.jpg", UriKind.Absolute); 
    hinh1.Source = new BitmapImage(hinh); 

    hinh1.ImageOpened+=hinh1_ImageOpened; //loadingbar will be disappear when this triggered 
} 

private void hinh1_ImageOpened(object sender, RoutedEventArgs e) 
{ 
    loading.IsActive = false; //this will disable the progressring. 
} 

和XAML:

<StackPanel HorizontalAlignment="Left" Height="597" VerticalAlignment="Top" Width="400"> 
     <Image x:Name="hinh1" Height="488" Stretch="Fill" ImageOpened="hinh1_ImageOpened"/> 
     <ProgressRing Name="loading" Height="109" IsActive="True" /> 
    </StackPanel> 

如果沒有WP8.1 SDK,你可以得到ProgressRing這裏:http://www.onurtirpan.com/onur-tirpan/english/windows-phone-english/using-progressring-in-windows-phone/

+0

非常感謝Onur Tirpan。我會盡力回覆結果。再次感謝 – user3506135

+0

。我已經完成了你的建議。謝謝你 – user3506135

+0

如何在同一時間加載多個圖像? – user3506135