views:

21

answers:

1

I am trying to bind a List of objects to an ItemsControl. The object has only two properties: Movie (a string) and Actors (an array of string). I can get the binding to work fine for the Movie. But I can't figure out the binding for the Actors array.

<ItemsControl x:Name="MovieList">
    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <StackPanel Width="100">
                <Border Margin="2">
                    <TextBlock Text="{Binding Movie, Mode=OneWay}" />
                </Border>
                <ListBox ItemsSource="{Binding Actors, Mode=OneWay}">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding}" />
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </StackPanel>
        </DataTemplate>
    </ItemsControl.ItemTemplate>
    <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <controlsToolkit:WrapPanel />
        </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>
</ItemsControl>

Any suggestions?

A: 
<ListBox ItemsSource="{Binding Actors, Mode=OneWay}">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding}" />
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>

this is wrong...you have to tell it what you want to bind to in the actors collection.

{Binding Path=ActorName} for example...since you only have it one way you could use displaymemberpath instead and just go: DisplayMemberPath="ActorName"

ecathell