Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
460
How to get the Listbox in a databound solution
posted

hi,

 I am using the example to bind to a collection that has an items collection.  The data template for the binding is a ListBox and I need to get that listbox once the data has been bound.  I need each listbox that is created once the binding is complete.  How do you do this?

 

<DataTemplate x:Key="ItemTemplate">

urce="{Binding BuddyList}" ContextMenu="{StaticResource cmListBuddyItems}" MouseDoubleClick="lb_MouseDoubleClick" Name="lbItems" >

<ListBox.Resources>

<Style TargetType="{x:Type ListBox}">

<Setter Property="Template">

<Setter.Value>

<ControlTemplate TargetType="{x:Type ListBox}">

<Grid>

<ScrollViewer Focusable="false">

<StackPanel Margin="1" IsItemsHost="true"/>

</ScrollViewer>

</Grid>

</ControlTemplate>

</Setter.Value>

</Setter>

</Style>

</ListBox.Resources>

<ListBox.ItemTemplate>

<DataTemplate>

<StackPanel Orientation="Horizontal" MouseRightButtonDown="StackPanel_MouseRightButtonDown">

<Image Source="{Binding Path=HotImageLocation}" Height="16" Width="16"/>

<Image Source="{Binding Path=BuddyStatusImageLocation}" Height="16" Width="16"/>

<TextBlock Text="{Binding Path=ChatUserName}" Margin="2,3"/>

</StackPanel>

</DataTemplate>

</ListBox.ItemTemplate>

</ListBox>

</DataTemplate>

<Style TargetType="{x:Type igOutlookBar:OutlookBarGroup}">

<Setter Property="Content" Value="{Binding}"/>

<Setter Property="ContentTemplate" Value="{StaticResource ItemTemplate}"/>

<Setter Property="Header" Value="{Binding Path=BuddyGroupName}"/>

</Style>