I have a listbox item template that contains visual states. I have DisplayStateBehaviors that set the states to either the on/off states. My implementation only 1/2 works. On initial display, the base state is active, regardless of the value in the DataContext. When the data in the DataContext changes, the proper state is activated.
How do I get the proper state displayed on initial display of the listbox.
For security reasons I can not copy/paste XAML or View-Model code.
Edit: While I can't copy/paste the real code, the following skeleton hopefully reproduces the problem.
In a globally visible resource file:
<DataTemplate x:Key="MyObjectItemTemplate">
<Grid>
<VisualStateManager.VisualStateGroups>
... blend goodness ...
</VisualStateManager.VisualStateGroups>
</Grid>
</DataTemplate>
The data context is passed into the data template by associating it with the ItemsTemplate attribute of the listbox in the main UI.
<ListBox ... ItemTemplate="{DynamicResource MyObjectItemTemplate}" .../>