【发布时间】:2015-10-30 04:38:20
【问题描述】:
组合框1
<ComboBox Grid.Column="1" Grid.Row="1" Height="23" HorizontalAlignment="Center" Margin="2,2,0,0" Name="comboBoxServer" VerticalAlignment="Top" Width="156" ItemsSource="{Binding Path=ServerNameList, Mode=OneWay}" SelectedIndex="0" SelectedItem="{Binding SelectedIndex}" SelectionChanged="comboBoxServer_SelectionChanged" Text="{Binding selectedServer, Mode=OneWayToSource,UpdateSourceTrigger=PropertyChanged}" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding serverCommand}" CommandParameter="{Binding ElementName=comboBoxServer, Path=SelectedValue}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>
组合框2
<ComboBox Grid.Column="1" Grid.Row="2" Height="23" HorizontalAlignment="Center" Margin="2,2,0,0" Name="comboBoxDBName" VerticalAlignment="Top" Width="156" ItemsSource="{Binding Path=DBNameList, Mode=OneWay}" SelectedItem="{Binding serverSelected, Mode=TwoWay}" >
</ComboBox>
我希望在第一个组合框中选择值时,第二个组合框应根据第一个组合框选择填充。
【问题讨论】:
-
语句
<i:InvokeCommandAction Command="{Binding serverCommand}" CommandParameter="{Binding ElementName=comboBoxServer, Path=SelectedValue}"/>的输出窗口是否有绑定失败? -
没有。没有这样的失败..
标签: wpf events mvvm combobox selectionchanged