【发布时间】:2017-08-05 01:53:59
【问题描述】:
可能是 Visual Studio 错误,但它绝对令人愤怒,我找不到解决方案,甚至找不到它发生的原因。
在我的应用程序中,我在可停靠面板的命名空间静态内容中有一个 XAML 文件列表。
程序运行良好,除了一些任意警告之外,程序中没有任何错误。
一些 XAML
<Window x:Class="Shell"
xmlns:ad="clr-namespace:AvalonDock;assembly=AvalonDock"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sc="clr-namespace:StaticContent"
xmlns:ve="clr-namespace:View_Edit"
Title="View" Width="1024" Height="800" Icon="/component/Images/View.png"
Loaded="OnLoaded" IsVisibleChanged="isVisibleChanged" Closing="OnClosing" Background="#E9ECFB"
WindowStyle="None">
<Grid x:Name="DockingRegion" Margin="0,50,0,0">
<ad:DockingManager x:Name="DockManager">
<ad:ResizingPanel>
<ad:DocumentPane Margin="0,0,10,0">
<sc:StartPage Title="Home Page" VerticalContentAlignment="Stretch"
onProjectOpenFail="StartPage_onProjectOpenFail"
onProjectOpenSuccess="StartPage_onProjectOpenSuccess"
onProjectCreateSuccess="StartPage_onProjectCreateSuccess"
onProjectCreateFail="StartPage_onProjectCreateFail"/>
</ad:DocumentPane>
<ad:DockablePane ad:ResizingPanel.ResizeWidth="300" x:Name="ExplorerPane" FontSize="14" FontWeight="Bold">
<sc:AboutTab x:Name="about" Title="About" FontSize="14" FontWeight="Bold"/>
<sc:ProcessExplorer x:Name="pxProcessExplorer" Title="Process Explorer" FontSize="14"/>
<sc:DataExplorer x:Name="adDataExplorer" Title="Data Explorer" FontSize="14"/>
<!--<sc:UREPExplorer x:Name="adUREPExplorer" Title="UREP Custom Navigation" FontSize="14" Visibility="Hidden"/>-->
</ad:DockablePane>
</ad:ResizingPanel>
</ad:DockingManager>
</Grid>
标签 sc: 是命名空间 StaticContent。命名空间包括这些文件。今天早上打开项目时,它找不到引用 XAML 页面的命名空间。在多次按re-build并收到一些“rebuild failed”之后,它才决定工作?
有什么想法吗?
【问题讨论】:
-
也在构建尝试之间打开和关闭项目。我没有改变其他任何东西。
-
设计器使用您编译的代码来检查命名空间,这意味着如果您的代码无法编译设计器找不到它,一些常见的解决方法是关闭所有设计器窗口之前编译,这消除了阻止工作室甚至尝试编译代码的智能感知错误,其次,如果您的代码在运行时出错可能会使设计器崩溃,从而导致各种奇怪的行为,因此请尽量避免在构造函数中初始化对象,关闭项目还强制刷新,以纠正同样可能导致问题的过时引用
-
我遇到了完全相同的问题。我在两台机器上获得了 TFS 的所有最新代码。一方面,它构建完美,另一方面,它找不到我的 Window 继承类,我的对话框都是基于该类,它们都报告错误。这很奇怪。
-
@JackMiller 你能解决这个问题吗?
标签: c# wpf xaml namespaces