在Windows 10应用程序中加载下一个图像时在flipview中显示进度条c#

时间:2016-03-03 04:12:22

标签: c# windows-runtime windows-10 windows-8.1-universal

我使用此代码在flipview中显示图像

XAML代码:

<Grid>    
  <FlipView x:Name="flpvwImageBind" 
            Margin="0,0,0,0" 
            HorizontalAlignment="Center" 
            VerticalAlignment="Center" 
            Loading="flpvwImageBind_Loading" 
            Loaded="flpvwImageBind_Loaded">
    <FlipView.ItemTemplate>
      <DataTemplate>
        <Image Source="{Binding Thumbnail}" 
               Stretch="Fill" 
               x:Name="image" 
               Margin="0,0,0,0" >
        </Image>
      </DataTemplate>
    </FlipView.ItemTemplate>
  </FlipView>
</Grid>

XAML.cs代码

flpvwImageBind.ItemsSource = ShowCastManager.Loadpopupimages(PersonID);

这里我绑定了来自网上的图片网址,所以加载下一张图片需要时间,所以我想在加载下一张图片之前显示进度条,怎么做呢..

1 个答案:

答案 0 :(得分:1)

在flipview之后放置进度环,并为图像控制添加已加载和加载事件

<Grid>    
<FlipView x:Name="flpvwImageBind" Margin="0,0,0,0" HorizontalAlignment="Center" VerticalAlignment="Center" Loading="flpvwImageBind_Loading" Loaded="flpvwImageBind_Loaded">
            <FlipView.ItemTemplate>
                <DataTemplate>
                    <Image Source="{Binding Thumbnail}" Loading="image_Loading" Loaded="image_Loaded" Stretch="Fill" x:Name="image" Margin="0,0,0,0" ></Image>
                </DataTemplate>
            </FlipView.ItemTemplate>
        </FlipView>
  <ProgressRing x:Name="progressring" Height="50" Width="50"/>
</Grid>

并将此代码放入您的cs文件

private void image_Loading(FrameworkElement sender, object args)
{ 
  progressring.IsActive = true;
}

private void image_Loaded(object sender, RoutedEventArgs e)
{
  progressring.IsActive = false;
}