'UserControl' 类型不支持直接内容 [英] The type 'UserControl' does not support direct content

查看:38
本文介绍了'UserControl' 类型不支持直接内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Outlook 2013 和 2016 VSTO 外接程序项目,并尝试将 WPF 用户控件添加到自定义任务窗格中,如 这里.

I have an Outlook 2013 and 2016 VSTO Add-in project and am trying to add a WPF user control to a custom task pane as described here.

我遇到的问题是,当我添加用户控件 (WPF) 时,它会为我生成一个带有网格的 WPF 控件,但会自动抛出'UserControl' 类型不支持直接内容"的错误.

The problem I have is when I add the User Control (WPF) it generates me a WPF control with a grid, but automatically throws an error of "The type 'UserControl' does not support direct content".

WPF 生成:

<UserControl x:Class="TestNamespace.UserControl1"
         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:TestNamespace"
         mc:Ignorable="d" 
         d:DesignHeight="300" d:DesignWidth="300">
<Grid>

</Grid>
</UserControl>

我知道过去我必须将 WPF 项目类型 guid 添加到 .proj 文件中才能使某些东西正常工作,但是添加它并没有什么区别(实际上它甚至不会按特定顺序加载).

I know in the past I have had to add the WPF project type guid to the .proj file to get some things to work, but adding this made no difference (in fact it would not even load when in a certain order).

原文:

<ProjectTypeGuids>{BAA0C2D2-18E2-41B9-852F-F413020CAA33};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

崩溃:

<ProjectTypeGuids>{BAA0C2D2-18E2-41B9-852F-F413020CAA33};{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

不会崩溃,但不会修复错误:

Doesn't crash, but doesn't fix the error:

<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{BAA0C2D2-18E2-41B9-852F-F413020CAA33};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

谁能指出我正确的方向?

Can anyone point me in the right direction?

更新

我尝试直接创建一个新的类库项目,添加一个 WPF 用户控件,然后添加对 System.Xaml 的引用,我遇到了同样的问题.

I tried creating a new class library project straight out of the box, added a WPF user control, then added the reference to System.Xaml and I have the same issue.

推荐答案

对于在 Visual Studio 2015 上遇到此问题的任何人,请尝试添加(如果尚未添加)System.Xaml 参考你的项目.Visual Studio 根本无法显示引用错误.

For anyone who having this problem on Visual Studio 2015, try to add (if it's not already added) System.Xaml reference to your project. Visual Studio simply fails to show reference error.

这篇关于'UserControl' 类型不支持直接内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆