【问题标题】:windows phone 8 longlistselector rebinding imagewindows phone 8 longlistselector 重新绑定图像
【发布时间】:2013-09-23 05:24:09
【问题描述】:

我正在访问谷歌图书 api 以在我的应用程序的图书结果页面中显示缩略图。我想做的是当用户立即访问图书列表时,我想从我的图书列表中显示“正在加载”的 png 图像image 文件夹,因为从 google 图书 api 加载缩略图需要一些时间。然后,原始缩略图将一张一张地加载到加载图像上,为用户提供良好的体验。问题是我如何重新绑定图像(即在加载加载图像后我想加载真正的缩略图)?这是相关的代码。知道如何以适当的方式做到这一点吗?

如果使用转换器,我不确定如何确定何时显示哪个图像?

    <DataTemplate x:Key="BooksItemTemplate">
        <Grid Margin="{StaticResource PhoneTouchTargetOverhang}" Background="Transparent">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions> 
            <Button Click="Button_Click_1" />
            <Image Source="Images/loading.jpg" Height="150" Width="150"/>
            <StackPanel Grid.Column="1" VerticalAlignment="Top">
                <TextBlock Text="{Binding BookTitle}" Style="{StaticResource PhoneTextNormalStyle}" TextWrapping="Wrap" FontFamily="{StaticResource PhoneFontFamilySemiBold}"/>
                <TextBlock Text="{Binding Identificationno}" Style="{StaticResource PhoneTextNormalStyle}" TextWrapping="Wrap" FontFamily="{StaticResource PhoneFontFamilySemiLight}"/>
            </StackPanel>
        </Grid>
    </DataTemplate>

 <phone:LongListSelector x:Name="bookslist" 
                                 Background="Transparent"  
                                 IsGroupingEnabled="False"                 
                                 ItemTemplate="{StaticResource BooksItemTemplate}"/>


 public BookCategoriesViewModel bookcategoriesvm;
    public BooksListing()
    {
        InitializeComponent();
        bookcategoriesvm = new BookCategoriesViewModel();
    }

    protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
    {
        base.OnNavigatedTo(e);
        string categoryid = string.Empty;
        if (NavigationContext.QueryString.TryGetValue("catid", out categoryid))
        {
           bookcategoriesvm.GetBookcategories(Convert.ToInt64(categoryid));              
        }

        bookslist.ItemsSource = bookcategoriesvm.BooksCategoriesList;
    }

【问题讨论】:

    标签: windows-phone-7 windows-phone-8 windows-phone


    【解决方案1】:

    最简单的方法可能是在缩略图完成下载时像这样将两个图像放在一起(底部的“加载图像”),它只会隐藏您的加载图像。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-09-23
      • 2014-07-01
      • 2013-09-24
      • 2013-11-14
      • 2014-03-12
      • 1970-01-01
      • 2014-01-15
      相关资源
      最近更新 更多