✅ Listbox issue

hey, having issues with a listbox template:
<ListBox x:Name="PersonList" SelectionMode="Multiple">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Label Content="{Binding Name}"/>
<Label Content="{Binding Surname}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<ListBox x:Name="PersonList" SelectionMode="Multiple">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Label Content="{Binding Name}"/>
<Label Content="{Binding Surname}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
can you guys tell me what's wrong here?
public RemovePersonList(List<Person> personList)
{
InitializeComponent();
PersonList.ItemsSource = personList;
}
//How person class looks:
class Person{
public string Name;
public string Surname;
//...
}
public RemovePersonList(List<Person> personList)
{
InitializeComponent();
PersonList.ItemsSource = personList;
}
//How person class looks:
class Person{
public string Name;
public string Surname;
//...
}
The issue is that the items show up but they are empty
3 Replies
Mąż Zuzanny Harmider Szczęście
nvm fixed it myself, just added {get;set;} to the end of name and surname
Unknown User
Unknown User7d ago
Message Not Public
Sign In & Join Server To View
MODiX
MODiX7d ago
If you have no further questions, please use /close to mark the forum thread as answered

Did you find this page helpful?