Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/308.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 关于定位器的WPF数据绑定问题_C#_Wpf_Data Binding_Viewmodellocator - Fatal编程技术网

C# 关于定位器的WPF数据绑定问题

C# 关于定位器的WPF数据绑定问题,c#,wpf,data-binding,viewmodellocator,C#,Wpf,Data Binding,Viewmodellocator,这可能是个愚蠢的问题,但我似乎无法解决问题 我有一个WPF项目,我想重命名它,并着手进行mercurial重构 总而言之,它似乎做得很好。唯一的问题是,我的viewmodel的datacontext似乎搞砸了 其中一页的示例如下所示 <Page x:Class="Cirdan.Excite.Views.ViewerPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http

这可能是个愚蠢的问题,但我似乎无法解决问题

我有一个WPF项目,我想重命名它,并着手进行mercurial重构

总而言之,它似乎做得很好。唯一的问题是,我的viewmodel的datacontext似乎搞砸了

其中一页的示例如下所示

<Page x:Class="Cirdan.Excite.Views.ViewerPage"
  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:controls="clr-namespace:Cirdan.Excite.Controls"
  xmlns:infrastructure="clr-namespace:Cirdan.Excite.Infrastructure"
  DataContext="{Binding ViewerViewModel, Source={x:Static infrastructure1:MainWindow.LocatorX}}"
  mc:Ignorable="d"
  d:DesignHeight="1024" d:DesignWidth="1280"
  Title="Viewer">

我得到的错误是LocatorX既不存在也不可访问。但是,我可以转到ViewModel的源代码,在那里定义了LocatorX,以便它知道它们,并且LocatorX是公共的


在重新命名之前,这一切都很正常,因此它以某种方式链接到它。

虽然我理解你的问题,但不清楚你到底在问什么

以下是我要做的步骤:

  • 首先进行暴力检查。也就是说,查看每个类和XAML(以及任何落后的代码),确保
    的所有实例都是正确的。还要确保使用的名称空间是正确的

  • 更正任何错误值后,请清理并重新生成项目

  • 如果仍然出现错误,可以重新启动visual studio(或WPF设计器)

我以前在这里遇到过一些有趣的问题,曾经需要验证我的程序集是否也构建到了正确的目标平台


如果仍然无法使其正常工作,请创建一个干净的项目并将代码重新合并到一起。

主窗口是否仍在Cirdan.exite.Infrastructure命名空间中定义或其命名空间已更改?您好,命名空间也已更改,但它们都使用相同的命名空间