将TextChanged和SelectionChanged链接在一起用于WPF ComboBox

时间:2012-12-20 16:25:32

标签: c# wpf combobox

我有这样一种情况,我想让输入到可编辑ComboBox的文本在被更改时被选中并调用TextChanged处理程序。原因是在组合框的SelectionChanged处理程序中完成了一些非常重要的工作。

ComboBox在后面的代码中定义如下:

<ListView.View>
            <GridView x:Name="callListView" AllowsColumnReorder="True" ColumnHeaderToolTip="Broadcast call targets" >
               <GridViewColumn Width="120">
                  <GridViewColumn.CellTemplate>
                     <DataTemplate>
                        <ComboBox ItemsSource="{Binding Path=extensions, RelativeSource={RelativeSource AncestorType=Window}}"
                                  Width="105" IsEditable="True" HorizontalAlignment="Center" Margin="0,0,0,0" BorderThickness="0"
                                  SelectedItem="{Binding Path=Key, Mode=OneWay}" SelectionChanged="chooseExtension_SelectionChanged"
                                  TextBoxBase.TextChanged="chooseExtension_TextChanged" IsTextSearchEnabled="False">
                           <ComboBox.Resources>
                              <sys:Double x:Key="{x:Static SystemParameters.VerticalScrollBarWidthKey}">15</sys:Double>
                           </ComboBox.Resources>
                        </ComboBox>
                     </DataTemplate>
                  </GridViewColumn.CellTemplate>
               </GridViewColumn>
            </GridView>
<!-- a bunch of unrelated stuff was removed to keep this simple -->
         </ListView.View>

在TextChanged成为ComboBox的SelectedValue后,是否有某种方法可以生成当前文本?

0 个答案:

没有答案