尝试在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,我已经检查过它不是null,我已经尽力确保它没有两个定义浮动。网上有一些关于WS应用程序无法绑定到界面的喋喋不休,但是Button中的ICommand工作得很好(我在同一个项目中测试过它)。
这是一个使用VS2013为Win 8.1构建的简单的WS应用程序。我正在使用ReactiveUI的5.4.0版本(如果这在这里有所不同)。在编写WS应用程序时,我是新手。任何关于我做错了什么的建议或者我可以做些什么来帮助调试这都是最有帮助的!
答案 0 :(得分:0)
计算机很奇怪。只需将其设为具体类RoutingState
,无论如何,接口可能会在ReactiveUI 6中消失