我有一种情况,我想让输入到可编辑 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?