Closed dtoth1 closed 1 year ago
I have to admit I'm not a WPF person and it'll take a bit before I can personally dive in here, but there are some steps you can take to help troubleshoot your own problem and maybe get an answer faster.
First, remove anything in the repro that doesn't contribute to showing the problem. Anything that isn't needed.
Why? Not only will it make it easier for us to look at, but sometimes removing stuff you think doesn't matter actually makes a difference.
~Next, try adding the PropertyChanged stuff to the interface. Again, not being a WPF guy, it may be that if the system doesn't see the event it won't get called.~ I see that the event is part of INotifyPropertyChanged
. I still have to wonder if there's something missing during proxy generation, something I can't put my finger on.
Let us know how it goes.
I'd also recommend searching for "Castle DynamicProxy" along with "WPF" and "INotifyProertyChanged." Autofac is automatically wrapping the model, sure, but the challenge will be in making sure the proxy/interceptor is right. That part is Castle.DynamicProxy. Other people appear to have hit a similar issue while not using Autofac, so limiting your search to things using Autofac may not find you the answer.
Dear @tillig, thanks for the comments, I removed the empty constructors and custom attributes, updated the code with AfContainer class as well. The Debug.WriteLines are present in code to mimic logging behavior without using a real logger implementation here in test app. I will search a little bit about Castle's dynamic proxy as well.
I don't think we can do anything here. If you find out that we can, we'd be happy to check out a pull request. Thanks!
Describe the Bug
I'm trying to intercept viewmodels' interfaces by interface interceptors. Defined a simple logging interceptor, registered at type registration and opened new windows which's DataContext is binded to the before mentioned viewmodel. The viewmodel is resolved via viewmodel locator, which gets the viewmodel from the built container. If I define .EnableInterfaceInterceptors() at viewmodel registration, it's propertychanged behavior gets broken, the view is not aware of the binded property's changes. Without .EnableInterfaceInterceptors() the binding is working fine.
Steps to Reproduce
Register a viewmodel as an interface's implementation and enable interface interception on it. Created a test app as you can see below:
MainWindow, which registers the viewmodel and builds-, sets the container
Window which has binded property
Viewmodel's interface
Viewodel
Interceptor
ViewModel locator
A static class to hold the Container with the registered types
Expected Behavior
Binding should work with .EnableInterfaceInterceptors() too.
Dependency Versions
TFM net6.0-windows WPF (UseWPF set to true in csproj)
Autofac: 7.0.0, tested with earlier versions as well Autofac.Extras.CommonServiceLocator: 6.0.1 Autofac.Extras.DynamicProxy: 6.0.1