1

我使用此代码在翻转视图中显示图像

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);

在这里,我正在绑定来自在线的图像 URL,因此加载下一张图像需要时间,所以我想在加载下一张图像之前显示进度条,如何做到这一点..

4

1 回答 1

1

在翻转视图之后放置进度环并为图像控件添加加载和加载事件

<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;
}
于 2016-03-03T04:28:26.620 回答