【问题标题】:Cannot resolve type 'Expander'无法解析类型“扩展器”
【发布时间】:2021-02-16 05:01:17
【问题描述】:

我有一个 Expander,它不再接受 AncestorType 属性中的 Binding 中的 Expander 值。它曾经可以工作,但自从我升级到 Xamarin 表单 5.0.0 版后,它不再工作了,Visual Studio 报告了以下错误:

错误 XFC0000 无法解析类型“扩展器”。

<xct:Expander.Header>
        <Image Source="ExpanderPlus.png" WidthRequest="30" HeightRequest="30" Rotation="180">
             <Image.Triggers>
                    <DataTrigger TargetType="Image"
                                 Binding="{Binding Source={RelativeSource AncestorType={x:Type Expander}}, Path=IsExpanded}"
                                 Value="True">
                            <Setter Property="Source" Value="ExpanderClose.png"/>
                    </DataTrigger>
             </Image.Triggers>
        </Image>
</xct:Expander.Header>

【问题讨论】:

标签: xaml xamarin.forms expander xamarin-community-toolkit


【解决方案1】:

由于 Expander 未在 Xamarin.Forms 中定义,因此您需要指定它在 AncestorType 中的 xct 命名空间(来自 Expander was not found in Xamarin Forms 5.0.0)中定义,类似于您使用它时不会做&lt;Expander ..&gt;&lt;xct:Expander ..&gt;

xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
Binding="{Binding Source={RelativeSource AncestorType={x:Type xct:Expander}},
                      Path=IsExpanded}" Value="True">

【讨论】:

    【解决方案2】:

    自 XF 5.0 起,ExpanderMediaElement 控制移至 Xamarin Community Toolkit 包的位置(您可以在 Xamarin.Forms 5 release notes 上找到相关信息)。

    请安装 Xamarin.Community.Toolkit 包并解析 ContentPage 标头上的引用,以便使用 xct 命名空间。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-27
    • 2017-06-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多