Advertisement
Jmat4119

Untitled

Jun 5th, 2014
362
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.55 KB | None | 0 0
  1.   <ItemsControl  ItemsSource="{Binding ShelfItemsCollection}" Name="shelfGridView" Margin="5" Visibility="Collapsed"VirtualizingStackPanel.IsVirtualizing="True"
  2.    ScrollViewer.CanContentScroll="False"   VirtualizingStackPanel.VirtualizationMode="Recycling"  >
  3.                 <ItemsControl.ItemTemplate>
  4.                         <DataTemplate>
  5.  <Border Style="{StaticResource ResourceKey=shelfBorderStyle}" MinWidth="200">
  6.  <Stackpanel>
  7.      <Image Width="150" Height="200" Stretch="Fill" Source="{Binding CoverImage}" ></Image>
  8.         <TextBlock Text="{Binding Title}"  TextTrimming="CharacterEllipsis"  MaxWidth="150"></TextBlock>
  9.        <TextBlock Text="{Binding Info}"  TextTrimming="CharacterEllipsis"  MaxWidth="150"  ></TextBlock>
  10.      </StackPanel>
  11. </Border>
  12.  
  13. Code    
  14.  
  15.  CoverImage property is of type ImageSource and is assigned using code
  16.  
  17. collectionitem.COnverImage=GetCOverImage(param1.param2);
  18.  
  19.     private ImageSource GetCoverImage(string bookId, string coverUrl)
  20.         {
  21.             ImageSource cover = null;
  22.             string cover_path = path of image file;
  23.             if (System.IO.File.Exists(cover_path))
  24.             {
  25.                 cover = new ImageSourceConverter().ConvertFromString(cover_path) as ImageSource;
  26.             }
  27.             else
  28.             {
  29.                 downloadCoverPage(coverUrl, cover_path); //download from a url and save to the local systme and then create ImageSource
  30.                 cover = new ImageSourceConverter().ConvertFromString(cover_path) as ImageSource;
  31.             }
  32.             return cover;
  33.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement