C# 来自Url\Device的数据模板中的图像
我的C# 来自Url\Device的数据模板中的图像,c#,.net,silverlight,windows-phone-7,C#,.net,Silverlight,Windows Phone 7,我的列表框中有这个数据模板: <local:SearchTemplateSelector.VideoTemplate> <DataTemplate> <Grid> <Rectangle Height="1" HorizontalAlignment="Stretch" VerticalAlignment="Top" Fill="Black" Opacity="0.3" /> <Grid>
列表框中有这个数据模板
:
<local:SearchTemplateSelector.VideoTemplate>
<DataTemplate>
<Grid>
<Rectangle Height="1" HorizontalAlignment="Stretch" VerticalAlignment="Top" Fill="Black" Opacity="0.3" />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Image Margin="0" HorizontalAlignment="Left" Source="{Binding Path=ImgUrl}" Width="100" Height="100" />
<Grid Grid.Column="1" Margin="10,0,8,0">
<Grid.RowDefinitions>
<RowDefinition Height="60"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Text="{Binding Name}" FontSize="20" Foreground="Black" TextWrapping="Wrap" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
<StackPanel Orientation="Horizontal" Margin="0,-5,0,0" Grid.Row="1">
<TextBlock Text="Views: " FontSize="20" Foreground="Black"/>
<TextBlock Text="{Binding ViewCount}" FontSize="20" Foreground="Black"/>
</StackPanel>
<TextBlock Text="{Binding TimeStr}" FontSize="20" Foreground="Black" Grid.Row="2" Margin="0,0,0,0" />
</Grid>
</Grid>
</Grid>
</DataTemplate>
</local:SearchTemplateSelector.VideoTemplate>
现在我有了从我的对象的ImgUrl绑定的图像。我想知道是否有可能制作这样的东西:
如果图像在设备中,请从设备获取图像,如果不下载图像并保存在设备上以备下次使用,则每个图像都有一个唯一的id,因此我可以使用id.png
保存图像。如果我理解您的意思正确,您必须向ImgUrl
属性添加逻辑。您必须在集合{}
中添加一些方法,该方法将尝试从隔离存储
加载图像,并捕获
异常,其中它将使用方法将图像加载并保存到隔离存储