Listview 增量列表视图不显示xamarin表单
我正在用Xamarin表单构建一个应用程序,我想使用 我看过这两个实现,但似乎没有一个能正常工作,所以我混合了这两个实现,以便能够运行我的代码 现在的问题是视图上没有显示任何内容 这是我的密码: ImovsPage.csListview 增量列表视图不显示xamarin表单,listview,xamarin,xamarin.forms,itemtemplate,Listview,Xamarin,Xamarin.forms,Itemtemplate,我正在用Xamarin表单构建一个应用程序,我想使用 我看过这两个实现,但似乎没有一个能正常工作,所以我混合了这两个实现,以便能够运行我的代码 现在的问题是视图上没有显示任何内容 这是我的密码: ImovsPage.cs public partial class ImovsPage : ContentPage { public Task Initialization { get; private set; } public static LinkedList<Imovel
public partial class ImovsPage : ContentPage
{
public Task Initialization { get; private set; }
public static LinkedList<Imovel> Imoveis { get; set; }
public ImovsPage()
{
Initialization = InitializeAsync();
InitializeComponent();
}
async Task InitializeAsync()
{
Imoveis = await Imovel.GetInitializedListAsync();
}
}
public分部类ImovsPage:ContentPage
{
公共任务初始化{get;private set;}
公共静态链接列表Imoveis{get;set;}
公共网页()
{
初始化=InitializeAsync();
初始化组件();
}
异步任务初始化同步()
{
Imoveis=await Imovel.GetInitializedListAsync();
}
}
ImovsPage.cs.xaml
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:plugin="clr-namespace:IncrementalListView.FormsPlugin;assembly=IncrementalListView.FormsPlugin"
x:Class="YmoApp.ImovsPage">
<ContentPage.Content>
<plugin:IncrementalListView
ItemsSource="{Binding Imoveis}"
PreloadCount="5">
<x:Arguments>
<ListViewCachingStrategy>RecycleElement</ListViewCachingStrategy>
</x:Arguments>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Image Source="{Binding Imagens}"/>
<Label Text="{Binding Valor}"/>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
<ListView.Footer>
<ActivityIndicator Margin="20" IsRunning="{Binding IsLoadingIncrementally}" IsVisible="{Binding IsLoadingIncrementally}"/>
</ListView.Footer>
</plugin:IncrementalListView>
</ContentPage.Content>
</ContentPage>
public class IncrementalViewModel : INotifyPropertyChanged, ISupportIncrementalLoading
{
public int PageSize { get; set; } = Settings.MaxImoveis;
public ICommand LoadMoreItemsCommand { get; set; }
public bool IsLoadingIncrementally { get; set; }
public bool HasMoreItems { get; set; }
public IncrementalViewModel()
{
LoadMoreItemsCommand = new Command(async () => await LoadMoreItems());
}
public event PropertyChangedEventHandler PropertyChanged;
async Task LoadMoreItems()
{
IsLoadingIncrementally = true;
Settings.incrementPage();
// Download data from a service, etc.
// Add the newly download data to a collection
foreach(Imovel imovel in await Imovel.GetInitializedListAsync()){
ImovsPage.Imoveis.AddLast(imovel);
}
HasMoreItems = (ImovListRequest.Total < Settings.Page * Settings.MaxImoveis);
IsLoadingIncrementally = false;
}
}
回收元素
查看模型
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:plugin="clr-namespace:IncrementalListView.FormsPlugin;assembly=IncrementalListView.FormsPlugin"
x:Class="YmoApp.ImovsPage">
<ContentPage.Content>
<plugin:IncrementalListView
ItemsSource="{Binding Imoveis}"
PreloadCount="5">
<x:Arguments>
<ListViewCachingStrategy>RecycleElement</ListViewCachingStrategy>
</x:Arguments>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Image Source="{Binding Imagens}"/>
<Label Text="{Binding Valor}"/>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
<ListView.Footer>
<ActivityIndicator Margin="20" IsRunning="{Binding IsLoadingIncrementally}" IsVisible="{Binding IsLoadingIncrementally}"/>
</ListView.Footer>
</plugin:IncrementalListView>
</ContentPage.Content>
</ContentPage>
public class IncrementalViewModel : INotifyPropertyChanged, ISupportIncrementalLoading
{
public int PageSize { get; set; } = Settings.MaxImoveis;
public ICommand LoadMoreItemsCommand { get; set; }
public bool IsLoadingIncrementally { get; set; }
public bool HasMoreItems { get; set; }
public IncrementalViewModel()
{
LoadMoreItemsCommand = new Command(async () => await LoadMoreItems());
}
public event PropertyChangedEventHandler PropertyChanged;
async Task LoadMoreItems()
{
IsLoadingIncrementally = true;
Settings.incrementPage();
// Download data from a service, etc.
// Add the newly download data to a collection
foreach(Imovel imovel in await Imovel.GetInitializedListAsync()){
ImovsPage.Imoveis.AddLast(imovel);
}
HasMoreItems = (ImovListRequest.Total < Settings.Page * Settings.MaxImoveis);
IsLoadingIncrementally = false;
}
}
public类IncrementalViewModel:INotifyPropertyChanged,支持incrementalloading
{
public int PageSize{get;set;}=Settings.MaxImoveis;
公共ICommand LoadMoreItemsCommand{get;set;}
public bool isloadingincremently{get;set;}
公共bool HasMoreItems{get;set;}
公共增量alviewmodel()
{
LoadMoreItemsCommand=new命令(异步()=>await LoadMoreItems());
}
公共事件属性更改事件处理程序属性更改;
异步任务LoadMoreItems()
{
IsLoadingIncremently=真;
Settings.incrementPage();
//从服务等下载数据。
//将新下载的数据添加到集合中
foreach(等待Imovel.GetInitializedListAsync()中的Imovel Imovel){
ImovsPage.imovis.AddLast(imovel);
}
HasMoreItems=(ImovListRequest.Total
这在