gpt4 book ai didi

wpf - Windows 8/RT/Store TextBox - 每次击键后更新文本绑定(bind)

转载 作者:行者123 更新时间:2023-12-04 05:59:57 24 4
gpt4 key购买 nike

有没有办法在每次击键后更新文本绑定(bind)?

我的 WPF 自定义 TextBox 使用 KeyUp 事件

private void MyTextBox_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
{
BindingExpression BE = GetBindingExpression(TextBox.TextProperty);
if (BE != null)
BE.UpdateSource();
}

但是 BindingExpressionWindows 8/RT/Store 中不存在。

最佳答案

我知道这个问题有点老了,但我今天遇到了这个问题并找到了一个非常简单的解决方案。也许它可以帮助某人:

<TextBox Text="{Binding BindingSource, UpdateSourceTrigger=PropertyChanged}"/>

将 UpdateSourceTrigger-Property 设置为“PropertyChanged”时,每次文本更改时都会调用 UpdateSource()-方法(即使焦点没有丢失)。

关于wpf - Windows 8/RT/Store TextBox - 每次击键后更新文本绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12215980/

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