gpt4 book ai didi

c# - 如何在 UWP 中为 ComboBox 启用自由文本

转载 作者:太空狗 更新时间:2023-10-29 23:20:07 27 4
gpt4 key购买 nike

我在我正在为 Windows 10 开发的 UWP 应用程序中添加了一个 ComboBox,但我无法做到这一点,以便用户可以在他们需要的值与任何不匹配的情况下输入自由文本可供选择的值。

我该怎么做?

According to MSDNComboBox.IsEditable 的描述是:

Gets or sets a value that enables or disables editing of the text in text box of the ComboBox.

这似乎是需要的。但是,这似乎仅适用于 WPF。

XAML 上似乎没有可设置的 IsEditable 属性:

IsEditable in XAML

在后面的代码中,当我尝试访问此属性时,它显示该属性只有 get 并且它始终返回 false:

IsEditable in code behind

请让我知道如何使这成为可能。谢谢!

最佳答案

我还没有尝试过,但这是在 UWP 上实现带有可编辑文本框的 ComboBox。

ComboBox with Editable Textbox

而且,基本上,Autosuggest 选项与可编辑的 ComboBox 完全不同 - Autosuggest 只是从当前项目列表中建议候选人,但不接受输入新的。要实现它,您需要像上面的人一样实现自定义用户控件。

2018 年 10 月添加 - 从 Windows 10 10 月 2018 更新开始,ComboBox 现在具有 IsEditable 属性。哇!还没有很好的记录,但这篇博文很有帮助。

XAML ComboBox IsEditable and Text Properties

关于c# - 如何在 UWP 中为 ComboBox 启用自由文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48938630/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com