我尝试在我的 Windows 8 手机应用程序上使用 Jet-Image Loader,它在表单上运行良好,但是一旦我尝试将 Jet-Image 缓存技术应用于在异步模式下绑定信息的 aync 方法,它就不起作用了,下面是我正在使用的代码:
XAML:
<ctl:LongListSelector x:Name="ListCards" VerticalAlignment="Center"
LayoutMode="Grid" ItemsSource="{Binding greetingsList}"
SelectionChanged="lstCards_SelectionChanged"
GridCellSize="210,170">enter code here
<ctl:LongListSelector.ItemTemplate>
<DataTemplate>
<StackPanel Width="200" Height="170" VerticalAlignment="Center">
<Image Source="{Binding ImgPath, Converter={StaticResource SampleJetImageLoaderConverter}}"
Width="180" Height="140"
HorizontalAlignment="Center"
Stretch="UniformToFill" />
</StackPanel>
</DataTemplate>
</ctl:LongListSelector.ItemTemplate>
</ctl:LongListSelector>
代码:
public partial class card_List3 : PhoneApplicationPage
{
public class GetGreetingSchema
{
public Uri ImgPath
{
get { return _ImgPath; }
set
{
SetProperty(ref _ImgPath, value);
}
}
}
public ObservableCollection<GetGreetingSchema> greetingsList { get; private set; }
public card_List3()
{
InitializeComponent();
greetingsList = new ObservableCollection<GetGreetingSchema>();
DataContext = this;
}
protected override async void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
try
{
await LoadDataAsync();
}
catch (Exception listbindException)
{
ReusableMethods.LogStackTrace(listbindException);
}
}
private async Task LoadDataAsync()
{
var dataSource = new Container().Resolve<IfellowsCollection>();
greetingsList = await dataSource.BindGreetingsList(CatId, Contenttype);
ListCards.ItemsSource = greetingsList;
}
}