如何在WPF中启用组合框的自由文本
本文关键字:自由 文本 组合 启用 WPF | 更新日期: 2023-09-27 17:50:41
如何在WPF中启用组合框的免费文本输入?我尝试了IsEditable="True",但即使这样也不起作用…
我的xaml语法是:<ComboBox SelectedValue="{Binding Path=CountryValue, Mode=TwoWay}" IsEditable="True" ItemsSource="{Binding Path=CountryValues, Mode=OneWay}"></ComboBox>
在网上找到的:链接
<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>