I have several AutoCompleteBox's in my usercontrol. The box's that are individual display the results with a white background which I would assume is the default. For whatever reason when I have an AutoCompleteBox within my ListBox.ItemContainerStyle the background on the popup is grey. Any idea why it would be different?
Here is example code on one that is white:
<controls:AutoCompleteBox Grid.Row="6" x:Name="FacilityCompleteBox" TextChanged="FacilityCompleteBox_OnTextChanged" ItemsSource="{Binding}" ValueMemberPath="ListName" SelectedItem="{Binding ElementName=patientVisitControl, Path=ClaimViewModel.SelectedFacility, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
LostFocus="CompleteBox_OnLostFocus" Text="{Binding ElementName=patientVisitControl, Path=ClaimViewModel.Visit.Facility.Facility.ListName}">
<controls:AutoCompleteBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=ListName}" />
</DataTemplate>
</controls:AutoCompleteBox.ItemTemplate>
</controls:AutoCompleteBox>
And here is my Listbox which has a grey background on the popup:
<ListBox x:Name="Resources" Grid.Row="8" ItemsSource="{Binding Path=ClaimViewModel.Claim.PatientVisitResources}" BorderBrush="Transparent" Background="White">
<ListBox.Resources>
<Style TargetType="ListBox">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBox">
<ItemsPresenter HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListBox.Resources>
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<!--<claimOverlay:PopupFilterControl x:Name="ResourceSearchFilter" SearchControlViewModel="{Binding}" ClaimOverlayWindow="{Binding ElementName=patientVisitControl, Path=ClaimOverlayWindow}" Height="30" MaxHeight="30"
DeleteResource="ResourceSearchFilter_OnDeleteResource" SelectCard="Default_OnSelectCard" />-->
<controls:AutoCompleteBox x:Name="ResourceCompleteBox" TextChanged="ResourceCompleteBox_OnTextChanged" ItemsSource="{Binding}" ValueMemberPath="ListName"
LostFocus="CompleteBox_OnLostFocus" Text="{Binding Path=ListName}">
<controls:AutoCompleteBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=ListName}" />
</DataTemplate>
</controls:AutoCompleteBox.ItemTemplate>
</controls:AutoCompleteBox>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
There aren't any other styles for ListBox within my user control.
So I assume there is a style somewhere in the ListBox that is making it turn grey so using the AutoCompleteBoxes ItemContainerStyle property I created the following style:
This style now changes my listbox popup background back to white to match the other AutoCompleteBoxes in my control.