问题标签 [propertychanged]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
2933 浏览

java - jFormattedTextField 的 Formatter.setCommitsOnValidEdit(true) 在第一次关注时不起作用

我有一个jFormattedTextField并且我设置setCommitsOnValidEdit为 true 然后我在“value”属性上添加了一个事件侦听器到“property change”。

首先,jFormattedTextField它在输入时不会调用事件侦听器方法。但是在“focusLost”上,它调用事件监听器,然后当它再次接收焦点时,它在键入时调用事件监听器。

我希望在任何时间发生任何变化后调用事件侦听器jFormattedTextField(即使在第一个焦点中)。

有什么问题?我该如何解决?

0 投票
1 回答
968 浏览

c# - Prism + MVVM + Access Keys + UpdateSourceTrigger="LostFocus" -- This doesn't let me save an updated textbox without first losing focus

Not really sure how to tackle this issue:

I have a "Save" button that has access keys attached to it... but, if I type something into a textbox and press the access keys to save, the textbox doesn't update my viewmodel because it never lost focus. Any way to solve this outside of changing the UpdateSourceTrigger to PropertyChanged?

0 投票
4 回答
35974 浏览

c# - 列表INotifyPropertyChanged 事件

我有一个带有字符串属性和 List 属性的简单类,并且实现了 INofityPropertyChanged 事件,但是当我执行 .Add 到字符串 List 时,此事件不会被命中,因此要在 ListView 中显示的转换器不会被命中。我猜更改的属性不会被添加到列表中......我怎样才能以某种方式实现这个来让属性更改事件命中???

我需要使用其他类型的集合吗?!

谢谢你的帮助!

0 投票
1 回答
162 浏览

wpf - 在属性更改回调中使用转换器或更新哪个更快?

我需要快速更新,所以我想知道哪个更快、更高效。

0 投票
2 回答
946 浏览

wpf - 使用 Treeview 和 PropertyChanged 时出现 NullReferenceException

NullReferenceException在我的视图模型中更新绑定属性时,我得到了一个。这只发生在我TreeView在视图中使用控件时。如果我用列表替换它,异常就会消失。

这是调试器在我的代码中中断的地方:

大约 30 次调用之后,通过许多PresentationFrameworkWindowsBase程序集,异常实际上发生在这里:

这是TreeView

如果我改用它ListBox,问题就会消失:

我不确定这会有所帮助,但这里是更新的属性:

这是更新该属性的调用:

有没有人经历过这样的事情?
我不知道是什么导致了这个问题,我很想只使用ListBox.

确实,我现在几乎必须使用ListBox
我怎么能解决这个问题?可能是PresentationFramework程序集中的错误吗?

此外,这是我的视图的代码隐藏,显示了项目更改事件的处理。

编辑

有人要求更多代码,所以这里是:

0 投票
2 回答
23912 浏览

c# - 监视 WPF 中 Telerik ScheduleView 控件的属性更改

我有一个类(WPF 控件)的 2 个属性:HorizontalOffsetVerticalOffset(都是 publicDouble的)。每当这些属性发生变化时,我都想调用一个方法。我怎样才能做到这一点?我知道一种方法 - 但我很确定这不是正确的方法(使用DispatcherTimer非常短的滴答间隔来监控属性)。

编辑更多内容:

这些属性属于 Telerik scheduleview 控件。

0 投票
1 回答
87 浏览

c# - 以动作为参数覆盖方法

我有一组方法允许用户轻松使用 PropertHasChanged 事件,然后允许进行一些额外的处理。这是方法:

对我来说很明显,有时我需要在 extraFunction 操作中使用旧值。这就是我打算这样做的方式:

您可能会注意到,extraFunction 操作现在需要两个参数。VS 在我创建该方法时没有问题(没有红色 qwigglies),但是当我构建它时会引发许多错误,表明第一种方法和第二种方法之间的用法不明确。如果是这种情况,那么我怎样才能实现我正在寻找的东西?

编辑

这是该方法的通常用法:

0 投票
2 回答
2675 浏览

wpf - TextBox bound to Decimal with UpdateSourceTrigger=PropertyChanged

I've been battling this issue for a while now and seem not to be able to come up with a concrete workaround - I have a TextBox which is bound to a decimal, and the binding has UpdateSourceTrigger set to PropertyChanged and is so by necessity (LostFocus won't work well in this case). The default behavior while I'm sure is somehow explainable, is not acceptable for my purposes, so I've tried the following StringFormat, which I had thought remedied the issue, but only partially and am now looking for something more concrete. My originaly fix was to add a string format to the binding...in my case it was

so when typing something like .12345 or 1.5 the solution works great, however if I type .01234, as soon as I hit the zero key, it removes the decimal I had just typed...which for obvious reasons would be disasterous in terms of data entry. I'm hoping that my familiarity with string formatting is just lacking. Wost case scenario I'll have my exposed property be a string and the setter and getter just convert to decimal, but that seems like a hacky solution.

Thanks!

Aj

0 投票
1 回答
3524 浏览

c# - 可编辑的 WPF 组合框不会触发 PropertyChanged

我有一个不可编辑的组合框来显示 SQL 数据库的所有表。

包含 UserControl 的属性看起来像这样,并且还实现了 INotifyPropertyChanged:

我使用以下数据绑定来填充 ComboBox:

但是我没有收到关于更改组合框的选定值的 PropertyChanged 通知。我的错在哪里?

0 投票
2 回答
661 浏览

c# - 如何从 C#/WPF 中的嵌套属性获取通知?

我的视图模型中有以下属性,并且视图绑定到该属性。

ActiveCategory除了(在 中_catManager)可以从其他事件(在此视图之外)更改的特殊情况外,一切正常。

我不想Category Manager在视图模型中公开整个,所以我只公开我需要的属性。这样做的最佳方法是什么,以便视图收到所有更改的通知,即使是那些未在此视图模型中触发的更改?