【发布时间】:2016-01-06 16:41:31
【问题描述】:
这可能是一个愚蠢的问题,但我似乎无法弄清楚问题所在。
我有一个 WPF 项目,我想重命名它并着手进行 mercurial 重构。
总而言之,它似乎做得很好,唯一的问题是我的视图模型的数据上下文似乎搞砸了。
其中一个页面的例子是这样的
<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 是公开的。
在重命名之前一切正常,所以它以某种方式链接到它
【问题讨论】:
-
您的 MainWindow 是否仍在 Cirdan.Excite.Infrastructure 命名空间中定义,或者其命名空间已更改?
-
嗨,命名空间也发生了变化,不过它们都使用相同的命名空间
标签: c# wpf data-binding viewmodellocator