我下载了Visual Studio 2022 for Mac,正在学习. NET毛伊岛
我一直在学习Build .NET MAUI UI with XAML [4 of 8] | .NET MAUI for Beginners基础教程
添加按钮和条目等内容一直很好,渲染也很正确,但当我添加<CollectionView>
时,我会重复错误,说
错误:XLS0112:应为"〉"。(MauiApp2)智能感知
Error: XLS0305: Closing tag for element '' was not found. (MauiApp2) IntelliSense
I am getting the same error for elements that are inside the as well such as <x:Array>
and <x:String>
下面是我的代码:MainPage.xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MauiApp2.MainPage">
<Grid RowDefinitions="100, Auto, *"
ColumnDefinitions=".75*, .25*"
Padding="10"
RowSpacing="10"
ColumnSpacing="10">
<Image Grid.ColumnSpan="2"
Source="dotnet_bot.png"
BackgroundColor="Orange"/>
<Entry Placeholder="Enter Task"
Grid.Row="1"/>
<Button Text="Add"
Grid.Row="1"
Grid.Column="1" />
<CollectionView Grid.Row="2" Grid.Column="2">
<CollectionView.ItemsSource>
<x:Array Type="{x:Type x:String}">
<x:String>apples</x:String>
<x:String>grapes</x:String>
<x:String>oranges</x:String>
</x:Array>
</CollectionView.ItemsSource>
</CollectionView>
</Grid>
</ContentPage>
我有
- 已多次重新启动Visual Studio
- 重新启动我的计算机
- 重写了我的代码
- 已检查VS更新
- 使用不同的模拟器
- 净化溶液
- 重建解
- 清洁后重建溶液
但我好像没办法解决问题
2条答案
按热度按时间xoefb8l81#
我把你的代码复制到了我的应用程序中,并在我的android模拟器上做了测试,但它在我这边运行良好。
您可以尝试删除bin文件夹和obj文件夹并重新生成它。如果不起作用,请尝试重新启动Visual Studio。
或者您可以创建一个新的演示并将您的代码复制到这个新的演示中,然后重试。
mdfafbf12#
不知道为什么会出现这种错误,但是一旦添加了
CollectionView
的这个基本属性,这种错误可能就会消失:ItemTemplate
:没有它,CollectionView将无效,无法显示任何内容。
也许这混淆了智能感知(尽管我还没有想到它为什么会给予这样的错误。它应该抱怨缺少ItemTemplate)。