I have the following ListBox
<ListBox x:Name="lbListItems"
<ListBox.ItemTemplate>
<DataTemplate>
<ToggleButton x:Name="btnItem">
<StackPanel Orientation="Horizontal" Width="956">
<toolkit:AutoCompleteBox x:Name="acbItem"</toolkit:AutoCompleteBox>
</StackPanel>
</ToggleButton>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
How can I set the ItemsSource for acbItem in code behind ? I cant access to it !
Use Loaded
event is a solution.
<toolkit:AutoCompleteBox Loaded="myControl_Loaded" ...
private void myControl_Loaded(object sender, RoutedEventArgs e)
{
toolkit:AutoCompleteBox myCombo = sender as toolkit:AutoCompleteBox;
// Do things..
}
But it's better to use MVVM approach to set ItemsSource
from XAML