在 Prism v2 for WPF 中使用 Unity 进行拦截(不适合我)
我无法使用 Prism v2(2009 年 10 月)进行拦截。我试图拦截任何公共属性的 Setter,然后在属性发生更改时触发 PropertyChanged 事件。我可以看到代码被执行(通过使用调试器单步调试或添加调试点)。但是,绑定到这些属性的 WPF 窗口控件不会更新。如果我订阅这些事件并打印到控制台,我可以打印出属性更改通知。
因此,如果 View 有一个文本框,它会更新 ViewModel 上的属性,那么 ViewModel 中的属性也会更新。但是,如果视图上的按钮(实现为 DelegateCommand)导致属性更新,则绑定到该属性的文本框(双向绑定模式)不会更新,即使事件被触发并且控制台已打印出来有关更新了哪个属性的信息。有人遇到过这个问题吗?
这是我编写的示例 WPF 应用程序。 WordPress 不允许上传 zip 文件,因此我将其重命名为具有 pdf 扩展名(将文件重命名为具有 zip 扩展名)。请让我知道我做错了什么。提前致谢。
I cannot get interception to work with Prism v2 (Oct 2009). I am trying to intercept the Setter for any Public Properties and then fire the PropertyChanged event if the property has changed. I can see that the code gets executed (by stepping through with the debugger or adding a debug point). However, the WPF Window controls that are bound to these properties do not get updated. If I subscribe to these events and print to the console, I can print out the property change notifications.
So, if the View has a textbox, which updates the property on the ViewModel, then the property in the ViewModel gets updated. However, if a button on the view (implemented as a DelegateCommand) causes the property to get updated, then the textbox (TwoWay Binding Mode) that is bound to that Property is not updated even though the event is triggered and the console has printed out the information about which property was updated. Has anyone encountered this issue?
Here is the sample WPF Application that I have written. Wordpress doesn't allow uploads of zip files, so I renamed it to have a pdf extension (rename the file to have a zip extension). Please let me know what I am doing wrong. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来透明代理拦截器存在问题。如果我将其从透明代理拦截器更改为虚拟属性并声明 VirtualMethodInterceptor,即从
到
我不知道为什么, 则该程序可以工作。有什么想法吗?
It seems like the problem exists with the TransparentProxyInterceptor. The program works if I change it from TransparentProxyInterceptor to making those properties virtual and declaring a VirtualMethodInterceptor i.e. from
to
I don't know why. Any idea?