Castle Windsor Dynamic Proxies を使用して WPF ViewModel を実装しようとしています。アイデアは、インターフェイス (例として以下の IPerson で十分です)、具体的なバッキング クラス、およびインターセプター (INotifyPropertyChanged の自動実装を提供するため) を提供することです。インターセプターの実装はこちら: http://www.hightech.ir/SeeSharp/Best-Implementation-Of-INotifyPropertyChange-Ever
私が見ている問題は、モデルを WPF コントロールにバインドすると、コントロールがモデルを INotifyPropertyChanged を実装していると認識しないことです。これは、Windsor がインターフェイスを明示的に実装しており、WPF がそれらが暗黙的であることを期待しているように見えるためだと思います (確信はありません)。
モデルへの変更がインターセプターによってキャッチされ、モデルに上げられるように、これを機能させる方法はありますか?
ライブラリのすべてのバージョンは最新です: Castle.Core 2.5.1.0 および Windsor 2.5.1.0
コードは次のとおりです。
// My model's interface
public interface IPerson : INotifyPropertyChanged
{
string First { get; set; }
string LastName { get; set; }
DateTime Birthdate { get; set; }
}
// My concrete class:
[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; }
}
// My windsor installer
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);
}
}