如何在WPF中启用组合框的自由文本输入? 我尝试使用IsEditable =“True”,但即使这样也行不通......
我的xaml语法是:
<ComboBox SelectedValue="{Binding Path=CountryValue, Mode=TwoWay}" IsEditable="True" ItemsSource="{Binding Path=CountryValues, Mode=OneWay}"></ComboBox>
答案 0 :(得分:10)
在网上找到这个: Link
<Window x:Class="LearnWPF.EditableComboBox.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="LearnWPF.EditableComboBox" Height="300" Width="300"
>
<Window.Resources>
<XmlDataProvider x:Key="items" XPath="//item">
<x:XData>
<items >
<item>01</item>
<item>02</item>
<item>03</item>
</items>
</x:XData>
</XmlDataProvider>
</Window.Resources>
<Grid>
<ComboBox IsEditable="True" DataContext="{StaticResource items}"
ItemsSource="{Binding}"/>
</Grid>
</Window>