【问题标题】:Invalid markup for wpf UserControl xamlwpf UserControl xaml 的标记无效
【发布时间】:2016-08-02 11:50:04
【问题描述】:

今天当我启动我的项目时,我所有包含UserControl 的视图都有:Invalid Markup 错误。

   <UserControl x:Class="ProjectName.View.LeftMenuControl"
                 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:local="clr-namespace:RaceFlightConfigurator.View"
                 xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
                 xmlns:UserControl="clr-namespace:ProjectName.View"
                 mc:Ignorable="d" 
                 d:DesignHeight="300" d:DesignWidth="300">
<UserControl:ConnectControl Margin="4"></UserControl:ConnectControl>

</UserControl>

我尝试Rebuild solution,从设计器中删除Shadow cache 文件夹等,但没有任何帮助...

项目运行良好。

【问题讨论】:

  • 这是设计模式还是运行模式?如果是前者,那么可能只是您的 ConnectControl 在设计时没有正确初始化。
  • 处于设计模式。用户控件有代码:public partial class LeftMenuControl : UserControl { public LeftMenuControl() { DataContext = new LeftMenuViewModel(); InitializeComponent(); } }
  • 如果它在今天之前有效,ConnectControl 有什么变化?现在(例如)是否需要数据库连接?
  • 我刚刚测试了空UserControl。没有代码等。当我尝试将其包含到 MainWindow 或其他 Views 时,同样的问题。

标签: c# wpf xaml user-controls


【解决方案1】:

我找到了解决方案。我在 Mac 上使用 Parallels,我的项目位于 /Mac/Username/Documents 等。当我将项目移动到 C: 路径时,一切正常。

【讨论】:

    猜你喜欢
    • 2010-10-29
    • 2012-10-03
    • 1970-01-01
    • 1970-01-01
    • 2014-05-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-02
    相关资源
    最近更新 更多