Type TouchEffect not found in xmlns with Xamarin.CommunityToolkit.MauiCompat.

huangapple go评论81阅读模式
英文:

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: &#39;Position 10:36. Type TouchEffect not found in xmlns http://xamarin.com/schemas/2020/toolkit&#39;

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:

&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
&lt;ContentPage xmlns=&quot;http://schemas.microsoft.com/dotnet/2021/maui&quot;
         xmlns:x=&quot;http://schemas.microsoft.com/winfx/2009/xaml&quot;
         xmlns:xct=&quot;http://xamarin.com/schemas/2020/toolkit&quot;
         x:Name=&quot;ArtistsPage&quot;
         x:Class=&quot;MediaServerApp.Artists&quot;
         xmlns:controls=&quot;clr-namespace:MediaServerApp&quot;
         NavigationPage.HasNavigationBar=&quot;False&quot;
         Title=&quot;&quot; &gt;
    &lt;FlexLayout Direction=&quot;Column&quot; xct:TouchEffect.Command=&quot;{Binding LongPressItem}&quot;&gt;
    ...

答案1

得分: 1

你可以将 xmlns:xct=&quot;http://xamarin.com/schemas/2020/toolkit&quot; 更改为 xmlns:xct=&quot;clr-namespace:Xamarin.CommunityToolkit.Effects;assembly=Xamarin.CommunityToolkit.MauiCompat&quot;。例如:

&lt;ContentPage xmlns=&quot;http://schemas.microsoft.com/dotnet/2021/maui&quot;
         xmlns:x=&quot;http://schemas.microsoft.com/winfx/2009/xaml&quot;
         xmlns:xct=&quot;clr-namespace:Xamarin.CommunityToolkit.Effects;assembly=Xamarin.CommunityToolkit.MauiCompat&quot;
         x:Name=&quot;ArtistsPage&quot;
         x:Class=&quot;MediaServerApp.Artists&quot;
         xmlns:controls=&quot;clr-namespace:MediaServerApp&quot;
         NavigationPage.HasNavigationBar=&quot;False&quot;
         Title=&quot;&quot; &gt;
    &lt;FlexLayout Direction=&quot;Column&quot; xct:TouchEffect.Command=&quot;{Binding LongPressItem}&quot;&gt;
    ...
英文:

You can change the xmlns:xct=&quot;http://xamarin.com/schemas/2020/toolkit&quot; to xmlns:xct=&quot;clr-namespace:Xamarin.CommunityToolkit.Effects;assembly=Xamarin.CommunityToolkit.MauiCompat&quot;. Such as:

&lt;ContentPage xmlns=&quot;http://schemas.microsoft.com/dotnet/2021/maui&quot;
         xmlns:x=&quot;http://schemas.microsoft.com/winfx/2009/xaml&quot;
         xmlns:xct=&quot;clr-namespace:Xamarin.CommunityToolkit.Effects;assembly=Xamarin.CommunityToolkit.MauiCompat&quot;
         x:Name=&quot;ArtistsPage&quot;
         x:Class=&quot;MediaServerApp.Artists&quot;
         xmlns:controls=&quot;clr-namespace:MediaServerApp&quot;
         NavigationPage.HasNavigationBar=&quot;False&quot;
         Title=&quot;&quot; &gt;
    &lt;FlexLayout Direction=&quot;Column&quot; xct:TouchEffect.Command=&quot;{Binding LongPressItem}&quot;&gt;
    ...

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.

huangapple
  • 本文由 发表于 2023年4月13日 15:57:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/76002992.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定