2014-11-19 13 views
0

현재 SideBarDemo를 ReactiveUI와 함께 C# 및 MonoMac으로 변환 중입니다. 공통 뷰 모델 클래스의 뷰인 NSTextField 및 NSTableCellView라는 두 개의 하위 클래스가 있습니다. 내 문제는 데이터 바인딩이 작동하도록 이러한 하위 클래스를 구현하는 방법을 모르겠다는 것입니다. 이러한 하위 클래스를 어떻게 구현하면 좋을까요?NSTextField 및 NSTableCellView의 하위 클래스를 ReactiveUI와 함께 사용하는 방법

다음에서 내 현재 상태를 볼 수 있습니다. ViewModel은 일반 속성이기 때문에 생성자에서 생성 된 바인딩이 작동하지 않는다는 것을 알고 있습니다. 그러나 어떤 인터페이스를 구현해야하는지 알 수 없었습니다.

[Register("MainCellView")] 
public class MainCellView : NSTableCellView, IViewFor<TreeItemViewModel> 
{ 
    public MainCellView() 
    { 
     this.OneWayBind (ViewModel, x => x.Name, x => x.TextField.StringValue); 
    } 

    public MainCellView(IntPtr ptr) : base(ptr) { } 

    public TreeItemViewModel ViewModel { get; set; } 

    object IViewFor.ViewModel 
    { 
     get { return this.ViewModel; } 
     set { this.ViewModel = (TreeItemViewModel)value; } 
    } 
} 

[Register("HeaderCellView")] 
public class HeaderCellView : NSTextField, IViewFor<TreeItemViewModel> 
{ 
    public HeaderCellView() 
    { 
     this.OneWayBind (ViewModel, x => x.Name, x => x.StringValue); 
    } 

    public HeaderCellView(IntPtr ptr) : base(ptr) { } 

    TreeItemViewModel _vm; 

    public TreeItemViewModel ViewModel { get; set } 

    object IViewFor.ViewModel 
    { 
     get { return this.ViewModel; } 
     set { this.ViewModel = (TreeItemViewModel)value; } 
    } 
} 

들으 사전에 많은

옌스 그러나

답변

0

, 나는 내가 가장 구현해야하는 인터페이스를 알아낼 수 없었다.

ReactiveUI 클래스에 대한 당신을하는 데 도움이 내장 된 서브 클래스가없는 경우, 당신은 당신의 클래스에 대한 INotifyPropertyChanged를 구현해야하고, 때 뷰 모델 변경 신호. 바인딩이 작동하기에 충분해야합니다!

+0

하이 폴. 감사. 나는 단지이 인터페이스를 구현하는 것을 결코 생각하지 못했다. 이제 완벽하게 작동합니다. – drvj