我已经编写了这个 WPF,其中我有绑定到 ObservableCollection 对象的组合框。当我在 Windows 7 中运行应用程序时,绑定工作得很好,一切都很好。当我在 WindowsXP 中运行它时,一切看起来都不错,但下拉菜单是空的。任何人都有这方面的经验,你有没有以某种方式解决它?
这是用于此的 XAML(它的一部分):
<StackPanel x:Name="spUnrecRxItems">
<Border BorderBrush="Silver" CornerRadius="3,3,3,3" BorderThickness="0,3,0,0" Height="Auto"
HorizontalAlignment="Left" Margin="23,6,0,0" Width="200" Background="#FFEFEEEE">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Name="tbUR1" Foreground="#FFDE2226" FontSize="14" FontWeight="Bold"
TextWrapping="Wrap" Width="Auto" HorizontalAlignment="Left" FontFamily="Arial" Grid.Row="0"
Margin="10,10,0,0" Text="{Binding DrugName}" />
<TextBlock Foreground="#FF484747" HorizontalAlignment="Left"
Margin="10,0,0,0" FontSize="12" Text="{Binding FillMinMaxDate}" Grid.Row="1" />
<TextBlock Foreground="#FF484747" HorizontalAlignment="Left"
Margin="10,0,0,0" FontSize="12" Text="{Binding PhysiciansName}" Grid.Row="2" />
<TextBlock ForceCursor="False" Foreground="#FF707170" HorizontalAlignment="Left"
Margin="10,0,0,0" Name="tbSourceCount" VerticalAlignment="Top" FontSize="12"
MouseDown="tbSource_MouseDown" Text="{Binding SourceCount, StringFormat=Source ({0})}" Grid.Row="3">
</TextBlock>
</Grid>
</Border>
<Expander x:Name="expManualRec" Background="DarkGray" Width="180" HorizontalAlignment="Center">
<Expander.Header>
<TextBlock HorizontalAlignment="Center" Text="Reconcile" Foreground="White" />
</Expander.Header>
<Grid Height="Auto">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ComboBox x:Name="cboReconType" HorizontalAlignment="Center" Margin="8 0 0 0" Width="160" Height="Auto" Grid.Row="1"
SelectionChanged="cboReconType_SelectionChanged" ItemsSource="{Binding RelativeSource={RelativeSource AncestorType=ItemsControl}, Path=DataContext.ReconTypes}" />
<ComboBox x:Name="cboRecReason" HorizontalAlignment="Center" Margin="8 0 0 0" Width="160" Height="Auto" Grid.Row="2"
SelectedValue="{Binding code}">
<ComboBox.Style>
<Style TargetType="ComboBox">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=cboReconType, Path=Text}" Value="Create A Question">
<Setter Property="ComboBox.Visibility" Value="Hidden" />
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=cboReconType, Path=Text}" Value="No Action">
<Setter Property="ComboBox.Visibility" Value="Visible" />
<Setter Property="ItemsSource" Value="{Binding RelativeSource={RelativeSource AncestorType=ItemsControl}, Path=DataContext.ReconReasons}" />
<Setter Property="DisplayMemberPath" Value="description" />
<Setter Property="SelectedValuePath" Value="code" />
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=cboReconType, Path=Text}" Value="Previous Questionnaire">
<Setter Property="ComboBox.Visibility" Value="Visible" />
<Setter Property="ItemsSource" Value="{Binding RelativeSource={RelativeSource AncestorType=ItemsControl}, Path=DataContext.InterviewQuestionnaires}" />
<Setter Property="DisplayMemberPath" Value="QuestionnaireName" />
<Setter Property="SelectedValuePath" Value="interviewquestionnaire_id" />
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=cboReconType, Path=Text}" Value="">
<Setter Property="ComboBox.Visibility" Value="Visible" />
</DataTrigger>
</Style.Triggers>
</Style>
</ComboBox.Style>
</ComboBox>