windows phone 8 uri图像无法显示

时间:2013-09-24 14:04:55

标签: c# xaml windows-phone-7 windows-phone-8 windows-phone

我真的不明白为什么我的缩略图没有显示。 。我正在显示来自Google book api的图片。有人可以帮我解决这个问题。这是相关的代码。

一个混乱:我需要创建一个位图图像并在转换器中将我的uri分配给它?没有用图像源设置字符串会不会有效?

  <DataTemplate x:Key="BooksItemTemplate">
        <Grid DataContext="{Binding}" Margin="{StaticResource PhoneTouchTargetOverhang}" Background="Transparent">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Button Name="btnAnswer4"> // problem is here
                <Image Name="thumbnailimage" Source="{Binding Images}" Width="110" Height="150" VerticalAlignment="Top"/>
            </Button>

            <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"                                  
                                 ItemTemplate="{StaticResource BooksItemTemplate}"/>

这是我的存储库类

  public class BookCategoriesRepository 
{

    private List<BookCategories> bookcategoriesList = new List<BookCategories>();
    public BookCategoriesRepository()
    {
        bookcategoriesList.Add(new BookCategories() { BookcategoryId = 1, CategoryId = 1, Identificationno = "ASDDDD", BookId = 1, BookTitle = "The power of art", Images = "http://bks1.books.google.com/books?id=mKbrGAAACAAJ&printsec=frontcover&img=1&zoom=5&source=gbs_api" });
        bookcategoriesList.Add(new BookCategories() { BookcategoryId = 2, CategoryId = 1, Identificationno = "ASDDDD1", BookId = 2, BookTitle = "Barto ´k, Hungary, and the Renewal of Tradition", Images = "http://bks1.books.google.com/books?id=mKbrGAAACAAJ&printsec=frontcover&img=1&zoom=5&source=gbs_api" });
        bookcategoriesList.Add(new BookCategories() { BookcategoryId = 3, CategoryId = 1,  Identificationno = "ASDDDD2", BookId = 3, BookTitle = "America Is the Prison", Images = "http://bks0.books.google.com/books?id=a3yRlKxxDtkC&printsec=frontcover&img=1&zoom=5&edge=curl&source=gbs_api" });
        bookcategoriesList.Add(new BookCategories() { BookcategoryId = 4, CategoryId = 1,  Identificationno = "ASDDDD3", BookId = 4, BookTitle = "Variations on a Blue Guitar", Images = "http://bks5.books.google.com/books?id=TKKd0TaNInAC&printsec=frontcover&img=1&zoom=5&edge=curl&source=gbs_api" });
        bookcategoriesList.Add(new BookCategories() { BookcategoryId = 5, CategoryId = 1,  Identificationno = "ASDDDD4", BookId = 5, BookTitle = "Sponsorship", Images = "http://bks7.books.google.com/books?id=VlON_hK0fVEC&printsec=frontcover&img=1&zoom=5&edge=curl&source=gbs_api" });
        bookcategoriesList.Add(new BookCategories() { BookcategoryId = 6, CategoryId = 1,  Identificationno = "ASDDDD5", BookId = 6, BookTitle = "I sensi delle arti", Images = "http://bks7.books.google.com/books?id=P7_pAAAAMAAJ&printsec=frontcover&img=1&zoom=5&source=gbs_api" });
        bookcategoriesList.Add(new BookCategories() { BookcategoryId = 7, CategoryId = 1,  Identificationno = "ASDDDD6", BookId = 7, BookTitle = "Mahler's Fourth Symphony", Images = "http://bks1.books.google.com/books?id=ybNqORIKIekC&printsec=frontcover&img=1&zoom=5&edge=curl&source=gbs_api" });
        bookcategoriesList.Add(new BookCategories() { BookcategoryId = 8, CategoryId = 1,  Identificationno = "ASDDDD7", BookId = 8, BookTitle = "The Commissariat of Enlightenment", Images = "http://bks0.books.google.com/books?id=a3yRlKxxDtkC&printsec=frontcover&img=1&zoom=5&edge=curl&source=gbs_api" });
        bookcategoriesList.Add(new BookCategories() { BookcategoryId = 9, CategoryId = 1,  Identificationno = "ASDDDD8", BookId = 9, BookTitle = "Smallest Giant", Images= "http://bks5.books.google.com/books?id=TKKd0TaNInAC&printsec=frontcover&img=1&zoom=5&edge=curl&source=gbs_api" });
        bookcategoriesList.Add(new BookCategories() { BookcategoryId = 10, CategoryId = 1, Identificationno = "ASDDDD9", BookId = 10, BookTitle = "Dame Joan Hammond", Images = "http://bks7.books.google.com/books?id=VlON_hK0fVEC&printsec=frontcover&img=1&zoom=5&edge=curl&source=gbs_api" });
        bookcategoriesList.Add(new BookCategories() { BookcategoryId = 11, CategoryId = 1, Identificationno = "ASDDDD10", BookId = 11, BookTitle = "Star Trek and Philosophy", Images = "http://bks1.books.google.com/books?id=ybNqORIKIekC&printsec=frontcover&img=1&zoom=5&edge=curl&source=gbs_api" });
        bookcategoriesList.Add(new BookCategories() { BookcategoryId = 12, CategoryId = 1, Identificationno = "ASDDDD11", BookId = 12, BookTitle = "Manejo De Conflictos Desde La Sabiduria Del Cine Y Las Canciones", Images = "http://bks0.books.google.com/books?id=a3yRlKxxDtkC&printsec=frontcover&img=1&zoom=5&edge=curl&source=gbs_api" });
        bookcategoriesList.Add(new BookCategories() { BookcategoryId = 13, CategoryId = 2, Identificationno = "ASDDDD12", BookId = 13, BookTitle = "Smallest Giant", Images = "http://bks5.books.google.com/books?id=TKKd0TaNInAC&printsec=frontcover&img=1&zoom=5&edge=curl&source=gbs_api" });
        bookcategoriesList.Add(new BookCategories() { BookcategoryId = 14, CategoryId = 2, Identificationno = "ASDDDD13", BookId = 14, BookTitle = "Afropolis", Images = "http://bks7.books.google.com/books?id=VlON_hK0fVEC&printsec=frontcover&img=1&zoom=5&edge=curl&source=gbs_api" });

    }

  public class BookCategories 
{
    private long _BookcategoryId { get; set; }
    public long BookcategoryId
    {
        get
        {
            return _BookcategoryId;
        }
        set
        {
            _BookcategoryId = value;              
        }
    }



    private long _BookId { get; set; }
    public long BookId
    {
        get
        {
            return _BookId;
        }
        set
        {
            _BookId = value;
        }
    }



    private long _CategoryId { get; set; }
    public long CategoryId
    {
        get
        {
            return _CategoryId;
        }
        set
        {
            _CategoryId = value;
        }
    }



    private string _BookTitle { get; set; }
    public string BookTitle
    {
        get
        {
            return _BookTitle;
        }
        set
        {
            _BookTitle = value;
        }
    }



    private string_Image { get; set; }
    public string Images
    {
        get
        {
            return _Image;
        }
        set
        {
            _Image = value;               
        }
    }



    private string _Identificationno { get; set; }
    public string Identificationno
    {
        get
        {
            return _Identificationno;
        }
        set
        {
            _Identificationno = value;
        }
    }


}

这是xaml.cs页面方法

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

1 个答案:

答案 0 :(得分:0)

有时它可能是由错误的日期+时间配置引起的。