【发布时间】:2014-04-07 02:32:28
【问题描述】:
我正在开发一个 WPF 应用程序,它运行良好。我注释掉了一个 if 检查以测试实用程序类中的某些内容,突然我的程序由于 XAML 解析异常而停止运行。它指向的 XAML 部分是开始标记和此属性:
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
完整的标签是这样的:
<Window x:Class="MyApplication.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="Auto" Width="Auto" WindowStartupLocation="CenterScreen" Topmost="False" KeyUp="KeyUpCheck" SizeToContent="WidthAndHeight" ResizeMode="NoResize" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" d:DesignWidth="441" d:DesignHeight="319">
确切的错误是这样的:
'在匹配指定绑定约束的类型'MyApplication.MainWindow'上调用构造函数引发了异常。行号“4”和行位置“291”。
该属性是我在视口中调整表单大小时生成的。我完全不知道为什么它会给我这个错误。有什么想法吗?
【问题讨论】:
-
需要贴出整个xaml才能找到异常原因
-
原因是我发布的属性。我的问题是如何解决它。
-
问题不在
标签或命名空间中,有时错误会在 xaml 中,编译器将指向 xaml 代码的第一个标签。因此,使用 标记 无法找到错误