ItemsControl ItemTemplate Binding

Are you sure the code you posted here IS the code you use in your solution? Because, this code works for me :

XAML

<ItemsControl ItemsSource="{Binding}">
    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <StackPanel>
                <TextBlock Text="{Binding OwnerData.OwnerName}"></TextBlock>
                <TextBlock Text="{Binding Credit}" />
            </StackPanel>
        </DataTemplate>
    </ItemsControl.ItemTemplate>
</ItemsControl>

Window’s Loaded Event

ObservableCollection<ForDisplay> items = new ObservableCollection<ForDisplay>();

for (int i = 0; i < 10; i++)
{
    items.Add(new ForDisplay() { OwnerData = new Owner() { OwnerId = i + 1, OwnerName = String.Format("Owner #{0}", i + 1) }, Credit = i + 1 });
}

DataContext = items;

Leave a Comment