Interception with Unity in Prism v2 for WPF (not working for me)
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 Proper开发者_JS百科tyChanged 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.
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
_container.RegisterType<SampleViewModel>()
.Configure<Interception>()
.SetDefaultInterceptorFor<SampleViewModel>(new TransparentProxyInterceptor())
.AddPolicy("NotifyPropertyChanged")
.AddMatchingRule(new PropertyMatchingRule("*", PropertyMatchingOption.Set))
.AddCallHandler(typeof(NotifyPropertyChangedCallHandler));
to
_container.RegisterType<SampleViewModel>()
.Configure<Interception>()
.SetDefaultInterceptorFor<SampleViewModel>(new VirtualMethodInterceptor())
.AddPolicy("NotifyPropertyChanged")
.AddMatchingRule(new PropertyMatchingRule("*", PropertyMatchingOption.Set))
.AddCallHandler(typeof(NotifyPropertyChangedCallHandler));
I don't know why. Any idea?
精彩评论