为什么我的对象在有值时仍然为空?
Why does my object remain null while it has a value?
我尝试显示投票数
在我的 itemDetails 页面中,我从页面项目中收到我的数据,但我的所有数据都是可读的(字符串 Titre、字符串描述、int Vote),当我单击我的按钮以访问项目详细信息页面时,我收到错误对象 null,什么时候试图阅读 INT。我试图进入 try.parse 或多种转换解决方案,但我找不到不好的写作
谢谢
FirebaseHelper firebaseHelper = new FirebaseHelper();
public ItemDetailsPage(string Titre, string Description, int Vote)
{
InitializeComponent();
MyTitre.Text = Titre;
MyDescription.Text = Description;
MyVote.Text = Vote.ToString();
}
// ITEM PAGE
protected async override void OnAppearing()
{
base.OnAppearing();
var allIdeas = await firebaseHelper.GetAllIdeas();
listIdeas.ItemsSource = allIdeas;
}
// BOUTTON VERS PAGE DETAILS
private async void OnItemSelected(Object sender, ItemTappedEventArgs e)
{
var details = e.Item as ItemsModel;
await Navigation.PushAsync(new ItemDetailsPage(
details.Titre,
details.Description ,
details.Vote));
}
---------------------------
<Label HorizontalOptions="Center"
FlexLayout.Grow="1"
x:Name=" MyVote" d:Name="Name!"
BackgroundColor="Gray"/>
<Label HorizontalOptions="Center"
FlexLayout.Grow="1"
x:Name=" MyVote" d:Name="Name!"
BackgroundColor="Gray"/>
也许删除 MyVote 前面的 space 可能会解决问题。
<Label HorizontalOptions="Center"
FlexLayout.Grow="1"
x:Name="MyVote" d:Name="Name!"
BackgroundColor="Gray"/>
我尝试显示投票数 在我的 itemDetails 页面中,我从页面项目中收到我的数据,但我的所有数据都是可读的(字符串 Titre、字符串描述、int Vote),当我单击我的按钮以访问项目详细信息页面时,我收到错误对象 null,什么时候试图阅读 INT。我试图进入 try.parse 或多种转换解决方案,但我找不到不好的写作
谢谢
FirebaseHelper firebaseHelper = new FirebaseHelper();
public ItemDetailsPage(string Titre, string Description, int Vote)
{
InitializeComponent();
MyTitre.Text = Titre;
MyDescription.Text = Description;
MyVote.Text = Vote.ToString();
}
// ITEM PAGE
protected async override void OnAppearing()
{
base.OnAppearing();
var allIdeas = await firebaseHelper.GetAllIdeas();
listIdeas.ItemsSource = allIdeas;
}
// BOUTTON VERS PAGE DETAILS
private async void OnItemSelected(Object sender, ItemTappedEventArgs e)
{
var details = e.Item as ItemsModel;
await Navigation.PushAsync(new ItemDetailsPage(
details.Titre,
details.Description ,
details.Vote));
}
---------------------------
<Label HorizontalOptions="Center"
FlexLayout.Grow="1"
x:Name=" MyVote" d:Name="Name!"
BackgroundColor="Gray"/>
<Label HorizontalOptions="Center"
FlexLayout.Grow="1"
x:Name=" MyVote" d:Name="Name!"
BackgroundColor="Gray"/>
也许删除 MyVote 前面的 space 可能会解决问题。
<Label HorizontalOptions="Center"
FlexLayout.Grow="1"
x:Name="MyVote" d:Name="Name!"
BackgroundColor="Gray"/>