如何解决XamlC错误XFC0000:无法解析类型'Popup'?
问题:XamlC错误XFC0000无法解析类型"Popup"
XamlC error XFC0000 : Cannot resolve type "Popup".
代码示例:
<xct:Popup xmlns:xct="http://xamarin.com/schemas/2020/toolkit" xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="SWD_Trening.NewEvent" IsLightDismissEnabled="False" Size="1000,600"/> <StackLayout> </StackLayout> </xct:Popup>
解决方法
安装Xamarin Community Toolkit包
右键项目打开「管理NuGet程序包」,搜索Xamarin.CommunityToolkit完成安装,注意所有平台项目(Android、iOS等)都要装,版本保持一致。核对命名空间
确认XAML里的命名空间xmlns:xct="http://xamarin.com/schemas/2020/toolkit"拼写正确,没有版本号或字符错误。修正后台代码继承关系
对应的NewEvent.xaml.cs文件中,类必须继承自Popup,示例代码:using Xamarin.CommunityToolkit.UI.Views; using Xamarin.Forms; namespace SWD_Trening { public partial class NewEvent : Popup { public NewEvent() { InitializeComponent(); } } }修复XAML结构错误
你的代码里<xct:Popup>用了自闭合标签(末尾/>),导致<StackLayout>不在Popup的内容范围内,改成非自闭合形式:<xct:Popup xmlns:xct="http://xamarin.com/schemas/2020/toolkit" xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="SWD_Trening.NewEvent" IsLightDismissEnabled="False" Size="1000,600"> <StackLayout> </StackLayout> </xct:Popup>清理重建项目
右键解决方案选择「清理解决方案」,再重新生成项目;或者重启IDE后再编译试试。
内容的提问来源于stack exchange,提问作者Marian34
相关产品推荐
相关产品推荐

