I am trying to implement WPM ViewModel using Dynamic Proxies Castle Windsor. The idea is that I want to provide an interface (for example, IPerson below as an example), a specific support class, and an interceptor (to ensure the automatic implementation of INotifyPropertyChanged). The interceptor implementation is here: http://www.hightech.ir/SeeSharp/Best-Implementation-Of-INotifyPropertyChange-Ever
The problem I see is that when I bind my models to WPF controls, the controls do not see the models as an implementation of INotifyPropertyChanged. I believe (but not sure) that this is because Windsor explicitly implements the interfaces, and WPF seems to expect them to be implicit.
Is there a way to make this work so that changes to the model are captured by the interceptor and pulled up to the model?
All versions of the libraries are the latest: Castle.Core 2.5.1.0 and Windsor 2.5.1.0
The code is as follows:
public interface IPerson : INotifyPropertyChanged
{
string First { get; set; }
string LastName { get; set; }
DateTime Birthdate { get; set; }
}
[Interceptor(typeof(NotifyPropertyChangedInterceptor))]
class Person : IPerson
{
public event PropertyChangedEventHandler PropertyChanged = (s,e)=> { };
public string First { get; set; }
public string LastName { get; set; }
public DateTime Birthdate { get; set; }
}
public class Installer : IWindsorInstaller
{
public void Install(IWindsorContainer container, IConfigurationStore store)
{
container.Register(
Component.For<NotifyPropertyChangedInterceptor>()
.ImplementedBy<NotifyPropertyChangedInterceptor>()
.LifeStyle.Transient);
container.Register(
Component.For<IPerson, INotifyPropertyChanged>()
.ImplementedBy<Person>().LifeStyle.Transient);
}
}
source
share