Mit*_*ins 5 winforms reactiveui
我刚刚将ReactiveUI添加到现有代码库中.当然,对于第一次控制我尝试了,我遇到了障碍.我正在使用嵌入在TabControl中的UserControl.代码看起来像这样:
public partial class TabPageControl : UserControl, IViewFor<TestViewModel>
{
public TabPageControl()
{
InitializeComponent();
ViewModel = new TestViewModel();
this.WhenActivated(dispose =>
{
dispose(this.Bind( ... ));
dispose(this.BindCommand( ... ));
});
}
}
Run Code Online (Sandbox Code Playgroud)
当我运行该应用程序时,我收到以下错误消息:
不知道如何检测TabPageControl何时被激活/停用,您可能需要实现IActivationForViewFetcher
那么,我该如何实现IActivationForViewFetcher?我不确定我该怎么做GetAffinityForView.我假设GetActivationForView我需要检查UserControl是否在TabControl中当前可见?
虽然我想了解如何实现方法IActivationForViewFetcher(尤其是我识别控件位于 VisualTree 中的部分),但问题的真正原因是我的主程序集没有适当的引用(控件是在班级集会上)。
我假设(因为我浏览了ReactiveUI源代码)ReactiveUI.Winforms.Registrations需要由主程序集实例化 - 其中包括注册ActivationForViewFetcher.
顺便说一句,类库是用C#编写的,主要组件是VB.NET。所以我不确定这是否导致了这个问题。
至少现在可以用了!
| 归档时间: |
|
| 查看次数: |
640 次 |
| 最近记录: |