This may be a very simple question, but at the moment I don’t actually know what to google.
If I had an object like this:
public class Employee
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
In my VM I have a list of employees (public List<Employee> Employees). It’s easy to bind this in my Xaml to a ListBox:
<ListBox ItemsSource={Binding Employees}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding FirstName}"/>
<TextBlock Text="{Binding LastName}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
But what if my list of employees would contain strings and not Employee objects? How could I bind these string values to the TextBlock in the data template?
Just write
{Binding}where you specify the binding.