英文:
Type TouchEffect not found in xmlns with Xamarin.CommunityToolkit.MauiCompat
问题
我试图使 MAUI 中的长按触摸效果起作用;通过各种线程,我最终使用了 Xamarin.CommunityToolkit.MauiCompat
包,以允许我使用尚未在 MAUI 中的 TouchEffect
。
我遇到的问题是当我运行这个时,在 InitializeComponent
调用时抛出异常 - Microsoft.Maui.Controls.Xaml.XamlParseException: 'Position 10:36. Type TouchEffect not found in xmlns http://xamarin.com/schemas/2020/toolkit'
奇怪的是 IntelliSense 知道 TouchEffect
在那里,当我开始输入 xct:
时,它建议我期望可用的一切,所以这似乎是一个运行时链接问题之类的。我无论如何都搞不清楚出了什么问题,谷歌搜索也无果。
这是我的页面的 XML:
<?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"
xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
x:Name="ArtistsPage"
x:Class="MediaServerApp.Artists"
xmlns:controls="clr-namespace:MediaServerApp"
NavigationPage.HasNavigationBar="False"
Title="" >
<FlexLayout Direction="Column" xct:TouchEffect.Command="{Binding LongPressItem}">
...
英文:
I'm trying to get a long press touch effect working with MAUI; through various threads on this I've ended up using the Xamarin.CommunityToolkit.MauiCompat
package to allow me to use the TouchEffect
that's not in MAUI yet.
The issue I'm having is when I run this, an exception is thrown on the InitializeComponent
call -
Microsoft.Maui.Controls.Xaml.XamlParseException: 'Position 10:36. Type TouchEffect not found in xmlns http://xamarin.com/schemas/2020/toolkit'
The weird thing is that Intellisense knows that TouchEffect
is there, when I start typing xct:
it suggests everything that I would expect to be available, so it's almost like it's a runtime linking issue or something. I can't for the life of me figure out what's going wrong and Google searches have been unfruitful.
Here's my page's XML:
<?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"
xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
x:Name="ArtistsPage"
x:Class="MediaServerApp.Artists"
xmlns:controls="clr-namespace:MediaServerApp"
NavigationPage.HasNavigationBar="False"
Title="" >
<FlexLayout Direction="Column" xct:TouchEffect.Command="{Binding LongPressItem}">
...
答案1
得分: 1
你可以将 xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
更改为 xmlns:xct="clr-namespace:Xamarin.CommunityToolkit.Effects;assembly=Xamarin.CommunityToolkit.MauiCompat"
。例如:
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:xct="clr-namespace:Xamarin.CommunityToolkit.Effects;assembly=Xamarin.CommunityToolkit.MauiCompat"
x:Name="ArtistsPage"
x:Class="MediaServerApp.Artists"
xmlns:controls="clr-namespace:MediaServerApp"
NavigationPage.HasNavigationBar="False"
Title="" >
<FlexLayout Direction="Column" xct:TouchEffect.Command="{Binding LongPressItem}">
...
英文:
You can change the xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
to xmlns:xct="clr-namespace:Xamarin.CommunityToolkit.Effects;assembly=Xamarin.CommunityToolkit.MauiCompat"
. Such as:
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:xct="clr-namespace:Xamarin.CommunityToolkit.Effects;assembly=Xamarin.CommunityToolkit.MauiCompat"
x:Name="ArtistsPage"
x:Class="MediaServerApp.Artists"
xmlns:controls="clr-namespace:MediaServerApp"
NavigationPage.HasNavigationBar="False"
Title="" >
<FlexLayout Direction="Column" xct:TouchEffect.Command="{Binding LongPressItem}">
...
I have tested this, and the project can deploy successfully.
In addition, there is a bug about [MauiCompat] TouchEffect not working, you can refer to the workaround in it or follow up this issue.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论