我可以从Firebase以后的数据库中看到我的数据,因为我在部署时在previsualizer中没有看到它正常吗?我很确定这不是显示数据的正确方法,但这是我唯一做过的方法
添加正确的行以添加伪造的Itmes但不起作用
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-
compatibility/2006"
d:DataContext="{d:DesignInstance x:Object}"
mc:Ignorable="d
<ListView x:Name="listIdeas"
ItemTapped="OnItemSelected">
<ListView.ItemTemplate>
<DataTemplate>
<!--<TextCell Detail="{Binding Titre}" Text="{Binding Description}" />-->
<ViewCell x:Name="listIdeas">
<Grid Padding="10" RowSpacing="10" ColumnSpacing="10">
<Grid.RowDefinitions>
<RowDefinition Height="60"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="90*"/>
<ColumnDefinition Width="10*"/>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Text="{Binding Titre}" HorizontalOptions="Start"/>
<Label Grid.Column="1" Text="{Binding Vote}" HorizontalOptions="End"/>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
// xaml.CS
protected async override void OnAppearing()
{
base.OnAppearing();
var allIdeas = await firebaseHelper.GetAllIdeas();
listIdeas.ItemsSource = allIdeas;
}
// Helpers
FirebaseClient firebase = new
FirebaseClient("https://xxx.firebaseio.com/");
public async Task<List<ItemsModel>> GetAllIdeas()
{
return (await firebase
.Child("Ideas")
.OnceAsync<ItemsModel>()).Select(item => new ItemsModel
{
Titre = item.Object.Titre,
Description = item.Object.Description,
Vote = item.Object.Vote
}).ToList();
}