我想自定义Expander
CommunityToolkit.Maui 包中的视图。安装Nuget包CommunityToolkit.Maui 8.0.1后,在App项目中使用没有问题。但是,如果在同一个解决方案中我添加一个 MAUI 类库项目(并安装 CommunityToCommunityToolkit.Maui 包),我会收到错误:
XFC0000 如果我使用 Expander,则无法解析类型“http://schemas.microsoft.com/dotnet/2022/maui/toolkit:ct:Expander”。是否允许在类库项目中使用 CommunityToCommunityToolkit.Maui ?
在App项目中,可以正确运行:
<?xml version="1.0" encoding="utf-8" ?\>
<ContentPage xmlns=".....
xmlns:ct="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
x:Class="MauiAppTest.PageTest"\>
<ct:Expander\>
<ct:Expander.Header\>
<Label Text="Click to expand" /\>
</ct:Expander.Header\>
<ct:Expander.Content\>
<StackLayout\>
<Label Text="Expanded content goes here" /\>
Add more content here as needed --\>
</StackLayout\>
</ct:Expander.Content\>
</ct:Expander\>
</ContentPage\>
但在类库项目中,这不能编译:
<?xml version="1.0" encoding="utf-8" ?>
<ContentView xmlns="....
xmlns:ct="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
x:Class="UserCtrlDr.DropDownCtrl">
<ct:Expander>
<ct:Expander.Header>
<Label Text="Click to expand" />
</ct:Expander.Header>
<ct:Expander.Content>
<StackLayout>
<Label Text="Expanded content goes here" />
Add more content here as needed -->
</StackLayout>
</ct:Expander.Content>
</ct:Expander>
</ContentView>`
XFC0000 无法解析类型“http://schemas.microsoft.com/dotnet/2022/maui/toolkit:ct:Expander”。UserCtrlDr (net8.0-android)、UserCtrlDr (net8.0-ios)、UserCtrlDr (net8.0-maccatalyst)、UserCtrlDr (net8.0-windows10.0.19041.0) D:\Applications\AppliTribunal\Apprentissage MAUI\excercice \MauiAppTest\UserCtrlDr\DropDownCtrl.xaml