gpt4 book ai didi

wpf - MVVMCross,WPF,XAML “Unable to resolve the binding creator - have you initialized Windows Binding”

转载 作者:行者123 更新时间:2023-12-03 10:44:59 25 4
gpt4 key购买 nike

我试图使用具有两个 View 和两个 View 模型的MVVMCross创建一个简单的WPF应用程序。我想要做的就是使用MvvmCross.BindingEx.Wpf nuget包在初始 View 上打开第二个 View 。这是我的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"/>
这是我的viewmodel类:
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.



我什至不知道该如何处理。有谁知道这可能是什么问题,我该如何解决?

最佳答案

在Stuart的指导下,我检查了this document,它用Xaml描述了西藏和里约热内卢。我在Setup.cs类中缺少了这段代码。

protected override void InitializeLastChance()
{
base.InitializeLastChance();

var builder = new MvxWindowsBindingBuilder();
builder.DoRegistration();
}

将其粘贴后,一切正常。谢谢!

关于wpf - MVVMCross,WPF,XAML “Unable to resolve the binding creator - have you initialized Windows Binding”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30382433/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com