【发布时间】:2019-12-01 06:37:29
【问题描述】:
我在代码中动态(必须是动态的)构建一个 Grid,并希望 Grid 成为 ListView 中唯一的东西。创建 Grid 的代码工作正常(经过测试),但现在我想将 Grid 放在 ListView 中,这样我就可以使用 ListView 的“下拉刷新”功能。
我的代码如下所示:
// ... Build the Grid
// Set the item source of the ListView to this one Grid
MatrixCells.ItemsSource = new ObservableCollection<Grid>(new List<Grid> { grid });
我的 Xaml 如下所示:
<ListView
x:Name="MatrixCells"
IsPullToRefreshEnabled="True"
RefreshCommand="{Binding ReloadProjectCommand}"
IsRefreshing="{Binding IsLoading, Mode=OneWay}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<!-- WHAT GOES HERE ?? -->
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
我的问题是如何将 ListView 中的整个项目绑定到我创建的网格?请参阅“这里发生了什么??”。
我试过了:
<Grid BindingContext="{Binding}" />
我知道这没有意义......还有其他一些事情,但无法让网格显示。
有什么想法吗?
谢谢。
【问题讨论】:
标签: listview xamarin xamarin.forms