tags:

views:

24

answers:

2

I have an Itemscontrol in my xaml, and I am calling a user control in the DateTemplate of ItemsControl like following

    <ScrollViewer Margin="0,0,0,0" BorderThickness="0">
        <ItemsControl x:Name="itemsStackPanel">
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <controls:UserItem Margin="0, 5, 0, 3"></controls:UserItem>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
    </ScrollViewer>

I already assign a list to ItemsControl.

    this.itemsStackPanel.ItemsSource = usersList;

and now I want to pass something extra property to my user control, which is inside DataTemplate, something like following, how do I do that?

    <controls:UserItem Margin="0, 5, 0, 3" CurrentColumnInfo={Binding oColumnInfo}></controls:UserItem>

the oColumnInfo object is kept in the codebehind. how do I pass that to each user item?

A: 

oColumnInfo should be part of your userList, if you want to bind using {Binding Path=oColumnInfo}

anivas
any better solution? I do not want to keep oColumnInfo inside userList, because userList is already of oColumnInfo. it will become circular dependency then.
Zain Shaikh
Not sure of your object structure, you can try IValueConverterand pass the corresponding oColumnInfo object based on any property of your usersList.
anivas