MVVMCross,WPF,XAML "Unable to resolve the binding creator - have you initialized Windows Binding"
MVVMCross, WPF, XAML "Unable to resolve the binding creator - have you initialized Windows Binding"
我正在尝试使用具有两个视图和两个视图模型的 MVVMCross 制作一个简单的 WPF 应用程序。我只想让初始视图上的按钮打开第二个视图,使用 MvvmCross.BindingEx.Wpf
nuget 包。这是我的 XAML 代码中的第一个标签:
<views:MvxWpfView
x:Class="FirstMVVMProject.WPF.Views.FirstView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:views="clr-namespace:Cirrious.MvvmCross.Wpf.Views;assembly=Cirrious.MvvmCross.Wpf"
xmlns:mvx="clr-namespace:mvx;assembly=Cirrious.MvvmCross.BindingEx.Wpf"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300" >
这是按钮:
<Button Width="50" Height="50" mvx:Bi.nd="Command GoCommand"/>
这是我的视图模型class:
namespace FirstMVVMProject.Core.ViewModels{
using System.Windows.Input;
using Cirrious.MvvmCross.ViewModels;
public class FirstViewModel : MvxViewModel
{
private MvxCommand _goCommand;
public ICommand GoCommand
{
get
{
_goCommand = _goCommand ?? new MvxCommand(GoToSecond);
return _goCommand;
}
}
private void GoToSecond()
{
base.ShowViewModel<SecondViewModel>();
}
}
}
当我尝试运行程序时,我在这个按钮所在的行上得到一个XamlParseException
,在异常快照的内部异常部分,它说
Unable to resolve the binding creator - have you initialized Windows Binding.
我什至不知道如何处理这个问题。有谁知道可能是什么问题以及我该如何解决它?
按照斯图尔特的指示,我查看了this document,其中描述了Xaml中的西藏和里约热内卢。我在 Setup.cs
class.
中遗漏了这段代码
protected override void InitializeLastChance()
{
base.InitializeLastChance();
var builder = new MvxWindowsBindingBuilder();
builder.DoRegistration();
}
在我粘贴之后,一切正常。谢谢!
我正在尝试使用具有两个视图和两个视图模型的 MVVMCross 制作一个简单的 WPF 应用程序。我只想让初始视图上的按钮打开第二个视图,使用 MvvmCross.BindingEx.Wpf
nuget 包。这是我的 XAML 代码中的第一个标签:
<views:MvxWpfView
x:Class="FirstMVVMProject.WPF.Views.FirstView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:views="clr-namespace:Cirrious.MvvmCross.Wpf.Views;assembly=Cirrious.MvvmCross.Wpf"
xmlns:mvx="clr-namespace:mvx;assembly=Cirrious.MvvmCross.BindingEx.Wpf"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300" >
这是按钮:
<Button Width="50" Height="50" mvx:Bi.nd="Command GoCommand"/>
这是我的视图模型class:
namespace FirstMVVMProject.Core.ViewModels{
using System.Windows.Input;
using Cirrious.MvvmCross.ViewModels;
public class FirstViewModel : MvxViewModel
{
private MvxCommand _goCommand;
public ICommand GoCommand
{
get
{
_goCommand = _goCommand ?? new MvxCommand(GoToSecond);
return _goCommand;
}
}
private void GoToSecond()
{
base.ShowViewModel<SecondViewModel>();
}
}
}
当我尝试运行程序时,我在这个按钮所在的行上得到一个XamlParseException
,在异常快照的内部异常部分,它说
Unable to resolve the binding creator - have you initialized Windows Binding.
我什至不知道如何处理这个问题。有谁知道可能是什么问题以及我该如何解决它?
按照斯图尔特的指示,我查看了this document,其中描述了Xaml中的西藏和里约热内卢。我在 Setup.cs
class.
protected override void InitializeLastChance()
{
base.InitializeLastChance();
var builder = new MvxWindowsBindingBuilder();
builder.DoRegistration();
}
在我粘贴之后,一切正常。谢谢!