如何修复Xamarin中的空白ListView页面

时间:2019-04-25 23:30:41

标签: xamarin visual-studio-2019

你好,我的列表变成白色我没有错误消息,并且部署失败。我在某个地方看到的东西是在我们第一次创建商品时发生的,或者相反的东西我不知道了。也许我没有以正确的方式创建课程,谢谢

enter code here

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         x:Class="jaune.Views.ContactPage">
<ContentPage.Content>
    <StackLayout Orientation="Vertical" >
        <Label Text="page des contacts" HorizontalOptions="Center"/>
       <ScrollView>
            <StackLayout HeightRequest="400">                    
                <ListView x:Name="ListContact" >
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <ViewCell>
                                <StackLayout Orientation="Horizontal" 
BackgroundColor="Gray" VerticalOptions="Center" Margin="25,0" 
Padding="10">
                                    <Image Source="carre"/>
                                    <Label Text="{Binding Nom}"/>
                                    <Label Text="{Binding Prenom}"/>
                                </StackLayout>
                            </ViewCell>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                 </ListView>
            </StackLayout>
       </ScrollView>
        <StackLayout VerticalOptions="End">
            <Label Text="Lorsque X personnes auront validé votre 
proposition vos contacts pourront partager votre idée"
                   HorizontalOptions="Center"
                   Margin="15" FontSize="20"/>
            <Label Text=" X contact minimum" HorizontalOptions="Center"/>
            <Button Text="valider"/>
    </StackLayout>
    </StackLayout>
</ContentPage.Content>
</ContentPage>

我不知道我是否使用好的方法制作列表视图

namespace jaune.Views
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
     public class Contact
        {
          public string Nom { get; set; }
          public string Prenom { get; set; }
        }
    public partial class ContactPage : ContentPage
    {
        List<Contact> contacts;
        public ContactPage()
        {

            InitializeComponent();

            contacts = new List<Contact>
            {
                new Contact { Nom = "le roi", Prenom = "Arthur" },
                new Contact { Nom = "Deja ", Prenom = "Boyd" },
                new Contact { Nom = "Jairo ", Prenom = "Alvarez" },
                new Contact { Nom = "Kaylee ", Prenom = "Spence" },
                new Contact { Nom = "Hana ", Prenom = "Ponce" },
                new Contact { Nom = "Aubree  ", Prenom = "Lynch" },
                new Contact { Nom = "Logan  ", Prenom = "Knight" },
                new Contact { Nom = "Caitlyn  ", Prenom = "Davila" },
                new Contact { Nom = "Elisha ", Prenom = "Howell" },
                new Contact { Nom = "Rayan  ", Prenom = "Moyer" },
                new Contact { Nom = "Harper  ", Prenom = "Summers" },
                new Contact { Nom = "Natalia  ", Prenom = "Jefferson" },
                new Contact { Nom = "Olive  ", Prenom = "Ponce" },
                new Contact { Nom = "Adan   ", Prenom = "Wilkerson" },
                new Contact { Nom = "Logan  ", Prenom = "Knight" },
                new Contact { Nom = "Darren   ", Prenom = "Mack" }
            };

            ListContact.ItemsSource = contacts;
        }
    }
}

0 个答案:

没有答案