Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <ItemsControl ItemsSource="{Binding ShelfItemsCollection}" Name="shelfGridView" Margin="5" Visibility="Collapsed"VirtualizingStackPanel.IsVirtualizing="True"
- ScrollViewer.CanContentScroll="False" VirtualizingStackPanel.VirtualizationMode="Recycling" >
- <ItemsControl.ItemTemplate>
- <DataTemplate>
- <Border Style="{StaticResource ResourceKey=shelfBorderStyle}" MinWidth="200">
- <Stackpanel>
- <Image Width="150" Height="200" Stretch="Fill" Source="{Binding CoverImage}" ></Image>
- <TextBlock Text="{Binding Title}" TextTrimming="CharacterEllipsis" MaxWidth="150"></TextBlock>
- <TextBlock Text="{Binding Info}" TextTrimming="CharacterEllipsis" MaxWidth="150" ></TextBlock>
- </StackPanel>
- </Border>
- Code
- CoverImage property is of type ImageSource and is assigned using code
- collectionitem.COnverImage=GetCOverImage(param1.param2);
- private ImageSource GetCoverImage(string bookId, string coverUrl)
- {
- ImageSource cover = null;
- string cover_path = path of image file;
- if (System.IO.File.Exists(cover_path))
- {
- cover = new ImageSourceConverter().ConvertFromString(cover_path) as ImageSource;
- }
- else
- {
- downloadCoverPage(coverUrl, cover_path); //download from a url and save to the local systme and then create ImageSource
- cover = new ImageSourceConverter().ConvertFromString(cover_path) as ImageSource;
- }
- return cover;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement