我正在WPF應用程序上工作。其中一個窗口包含6個組合框。WPF多個組合框通信
<ComboBox x:Name="ScenarioIDcb" Margin="0,5,0,2" Height="24" ItemsSource="{Binding}" SelectionChanged="ScenarioIDcb_SelectionChanged"/>
<ComboBox x:Name="ScenarioNamecb" Margin="0,2,0,2" Height="24" ItemsSource="{Binding}"/>
<ComboBox x:Name="ScenarioDescriptioncb" Margin="0,2,0,2" Height="24" ItemsSource="{Binding}"/>
<ComboBox x:Name="StepIDcb" Margin="0,2,0,2" Height="24" ItemsSource="{Binding}"/>
<ComboBox x:Name="StepNamecb" Margin="0,2,0,2" Height="24" ItemsSource="{Binding}"/>
<ComboBox x:Name="StepDescriptioncb" Margin="0,2,0,2" Height="24" ItemsSource="{Binding}"/>
<ComboBox x:Name="Expectedresultcb" Margin="0,2,0,2" Height="24" ItemsSource="{Binding}"/>
它們都綁定到一個可觀察到的字符串集合(ExcelColumnames)。
private void SetCBDataContext()
{
if (this.ExcelColumnames != null && this.ExcelColumnames.Count > 0)
{
ScenarioIDcb.DataContext = this.ExcelColumnames;
ScenarioNamecb.DataContext = this.ExcelColumnames;
ScenarioDescriptioncb.DataContext = this.ExcelColumnames;
StepIDcb.DataContext = this.ExcelColumnames;
StepNamecb.DataContext = this.ExcelColumnames;
StepDescriptioncb.DataContext = this.ExcelColumnames;
Expectedresultcb.DataContext = this.ExcelColumnames;
}
}
我想達到什麼是,如果在組合框中的一個用戶選擇的值,它應該不會出現到其他組合框。如果用戶在同一個組合框中選擇其他值,則先前選擇的值應出現在其他組合框中以供選擇。請指導我。
感謝Priyank