我的用户控件中有几个 AutoCompleteBox。单独的框以白色背景显示结果,我认为这是默认设置。无论出于何种原因,当我的 ListBox.ItemContainerStyle 中有一个 AutoCompleteBox 时,弹出窗口的背景是灰色的。知道为什么会有所不同吗?
这是白色的示例代码:
<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>
这是我的列表框,它在弹出窗口中有灰色背景:
<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>
我的用户控件中没有任何其他 ListBox 样式。