c# - “{”后使用的类型“x”必须是标记扩展。错误代码 0x09c6
问题描述
在我的一个用户控件中构建我的解决方案时遇到这个奇怪的错误,该用户控件有一个绑定到模型类的数据模板。
<UserControl
x:Class="MyApp.View.MyMainUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MyApp.View"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:model="using:MyApp.Model.Entity"
Loaded="UserControl_Loaded"
Unloaded="UserControl_Unloaded"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="400">
<UserControl.Resources>
<ResourceDictionary>
<DataTemplate x:Key="MyTemplate" x:DataType="model:SomeClass" >
<local:MyUserControl MySomeClass={x:Bind} />
</DataTemplate>
</ResourceDictionary>
</UserControl.Resources>
有趣的是,如果我用 textblock 替换“MyUserControl”,则解决方案构建得很好。我立即用“MyUserControl”替换了文本块,它构建成功。我再次重建,它失败并出现同样的错误。关于这个问题的任何亮点为什么会发生?
这个错误“{”之后使用的类型“x”必须是标记扩展名”是随机 XAML 错误还是特定错误?在什么情况下我会出现错误。如果我可以提醒你们,没有语法错误。以及 MyUserControl 的声明代码,
<UserControl
x:Class="MyApp.View.MyUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="400">`
`
使用 Visual Studio 19 版本 16.3.8
解决方案
您需要将{x:Bind}
引号括起来:
<local:MyUserControl MySomeClass="{x:Bind}" />
推荐阅读
- javascript - 如何在反应应用程序中集成谷歌登录身份验证
- store - 创建新帐户后无法验证 Google 开发者帐户的 ID
- firebase - 删除后生成相同的文档ID
- apache-kafka - Kafka Streams 没有获取 max.poll.records 和其他配置
- react-table - React-table - 自定义排序,以便某个值始终位于末尾
- r - 使用 purr:map 过滤和变异嵌套的鸢尾花数据集
- javascript - 想要迭代数组但增加事件的计数
- azure-devops - 如何使用管道变量部署应用服务作为要下载的工件?
- html - 无法获得与父级对齐的 100% 宽度
我在获得一张
width: 100%
与它的父 div 齐平的桌子时遇到了一些麻烦。出于某种原因,在表格的任一侧都可以看到小于 1 像素的间隙。我已经尝试将所有边距和填充设置为 0 以及设置 div 的最小和最大宽度,但它仍然不会使用所有可用内容。非常感谢有人可以为此提供任何帮助。这是表格的 css 和它的父 div 以及问题的一些图像:
.library
- docker - docker-compose with adminer & mariadb 在尝试数据库连接时显示 403