反应 UI 中的 XAML 转换器错误



尝试在Windows应用商店应用程序中使用ReactiveUI的MVVM框架时,我收到以下神秘错误:

Error: Converter failed to convert value of type 'ReactiveUI.RoutingState, ReactiveUI, 
Version=5.4.0.0, Culture=neutral, PublicKeyToken=null' to type 'IRoutingState'; 
BindingExpression: Path='Router' DataItem='MVVMTestWS.AppBootstrapper'; target element 
is 'ReactiveUI.Xaml.RoutedViewHost' (Name='null'); target property is 'Router' 
(type 'IRoutingState'). 

Xaml 如下所示:

<Page
    x:Class="MVVMTestWS.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:MVVMTestWS"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:Xaml="using:ReactiveUI.Xaml"
    mc:Ignorable="d">
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Xaml:RoutedViewHost Router="{Binding Router}"  HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" />
    </Grid>
</Page>

AppBootstrapper 对象如下所示:

public class AppBootstrapper : ReactiveObject, IScreen
{
    public IRoutingState Router { get; private set; }
    public AppBootstrapper(IMutableDependencyResolver dependencyResolver = null, IRoutingState testRouter = null)
    {
        Router = testRouter ?? new RoutingState();
        dependencyResolver = dependencyResolver ?? RxApp.MutableResolver;
        // Bind 
        RegisterParts(dependencyResolver);
        // TODO: This is a good place to set up any other app 
        // startup tasks, like setting the logging level
        LogHost.Default.Level = LogLevel.Debug;
        // Navigate to the opening page of the application
        Router.Navigate.Execute(new HomePageVM(this));
    }

这个错误让我感到困惑!路由器被明确声明为 IRoutingState,我已经检查了它是否不为空,并且我已经尽力确保它没有两个定义。网络上有一些关于WS应用程序在绑定接口时遇到问题的讨论,但是按钮中的ICommand工作得很好(我在同一项目中对其进行了测试)。

这是一个使用VS2013为Win 8.1构建的简单WS应用程序。我正在使用 ReactiveUI 的 5.4.0 版本(如果这在这里有所不同)。在编写 WS 应用程序时,我是新手。任何关于我做错了什么的建议,或者我可以做些什么来帮助调试这个问题,这将是最有帮助的!

计算机很奇怪。只需将其作为具体的类RoutingState,界面可能会在ReactiveUI 6中消失

最新更新