微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Rg.Plugins.Popup页面上的“属性内容设置不止一次”

如何解决Rg.Plugins.Popup页面上的“属性内容设置不止一次”

我是移动开发的新手,正在将Xamarin.Forms项目转换为.NETStandard库。原始程序员正在使用Rg.Plugins.Popup(用于弹出页面)。

我看到以下 design-time 错误...

Design-Time Error

注意事项:

视图:
这是整个视图。感谢您提供任何见识。

<?xml version="1.0" encoding="UTF-8"?>
<pages:PopupPage xmlns="http://xamarin.com/schemas/2014/forms"
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 xmlns:forms="clr-namespace:FFImageLoading.Svg.Forms;assembly=FFImageLoading.Svg.Forms"
                 xmlns:forms1="clr-namespace:Lottie.Forms;assembly=Lottie.Forms"
                 xmlns:popupViews="clr-namespace:ETC.Operations.pulse.Mobile.ViewContent.PopupViews;assembly=ETC.Operations.pulse.Mobile"
                 xmlns:animations="clr-namespace:Rg.Plugins.Popup.Animations;assembly=Rg.Plugins.Popup"
                 xmlns:pages="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup"
                 x:Class="ETC.Operations.pulse.Mobile.Views.GeneralPopupPage" 
                 BackgroundColor="Transparent">

    <pages:PopupPage.Animation>
        <animations:ScaleAnimation PositionIn="Bottom" PositionOut="Center" ScaleIn="1" ScaleOut="0.7" DurationIn="700" EasingIn="BounceOut" />
    </pages:PopupPage.Animation>
    
    <ScrollView
        HorizontalOptions="Center"
        VerticalOptions="Center">
        <AbsoluteLayout>
            <Frame
                x:Name="FrameContainer"
                Margin="15"
                HorizontalOptions="Center"
                BackgroundColor="White">
                <StackLayout
                    IsClippedToBounds="True"
                    Padding="10,5"
                    Spacing="3"
                    WidthRequest="250"
                    HeightRequest="320">

                    <!-- Content -->
                    <popupViews:CircuitTechView x:Name="viewCircuitTech" IsVisible="{Binding IsViewCircuitTechVisible}"  VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"/>
                    <forms1:AnimationView 
                        x:Name="animationView"
                        Animation="animation-w320-h320.json"
                        Loop="False" 
                        IsEnabled="False"
                        IsVisible="False"
                        Speed=".7"
                        OnFinish="AnimationView_OnOnFinish"
                        HorizontalOptions="CenterandExpand"
                        VerticalOptions="CenterandExpand"
                        HeightRequest="200"
                        WidthRequest="175">
                    </forms1:AnimationView>


                </StackLayout>
            </Frame>

            <ContentView AbsoluteLayout.LayoutFlags="PositionProportional" AbsoluteLayout.LayoutBounds="1,-1,-1" BackgroundColor="Transparent">

                <ContentView.GestureRecognizers>
                    <TapGestureRecognizer Command="{Binding CloseAllCommand}"/>
                </ContentView.GestureRecognizers>

                <Image
                    x:Name="CloseImage"
                    HeightRequest="30"
                    WidthRequest="30">
                    <Image.source>
                        <OnPlatform
                            x:TypeArguments="ImageSource"
                            Android="close_circle_button.png"
                            iOS="close_circle_button.png"
                            WinPhone="Assets/close_circle_button.png"/>
                    </Image.source>
                </Image>

                /* HERE IS WHERE ITHE ISSUE IS */
                <forms:SvgCachedImage 
                    Source="resource://ETC.Operations.pulse.Mobile.Images.close.svg" 
                    HeightRequest="30"
                    WidthRequest="30">
                    <forms:SvgCachedImage.GestureRecognizers>
                        <TapGestureRecognizer Command="{Binding CloseAllCommand}" CommandParameter="emptyValue" />
                    </forms:SvgCachedImage.GestureRecognizers>
                </forms:SvgCachedImage>

            </ContentView>
        </AbsoluteLayout>
    </ScrollView>

</pages:PopupPage>

解决方法

您最里面的ContentView包含两个元素,一个Image和一个SvgCachedImage。如果要有多个孩子,则需要将它们放置在布局容器中

,

ContentView只能有一个孩子/布局。

就像错误所暗示的那样,“属性设置不止一次”,您有2张图像(在这种情况下,该图像计为布局或子级),并且必须将它们放置在您喜欢的布局内(StackLayout,Grid) ,AbsoluteLayout等...)

这样,您在ContentView中只有一个版式作为子级,就像这样:

<ContentView AbsoluteLayout.LayoutFlags="PositionProportional" AbsoluteLayout.LayoutBounds="1,-1,-1" BackgroundColor="Transparent">
            <ContentView.GestureRecognizers>
                <TapGestureRecognizer Command="{Binding CloseAllCommand}"/>
            </ContentView.GestureRecognizers>

            <StackLayout>
                <Image
                    x:Name="CloseImage"
                    HeightRequest="30"
                    WidthRequest="30">
                    <Image.Source>
                        <OnPlatform
                            x:TypeArguments="ImageSource"
                            Android="close_circle_button.png"
                            iOS="close_circle_button.png"
                            WinPhone="Assets/close_circle_button.png"/>
                    </Image.Source>
                </Image>

                <!-- No more issues in your layout :) -->
                <forms:SvgCachedImage 
                    Source="resource://ETC.Operations.Pulse.Mobile.Images.close.svg" 
                    HeightRequest="30"
                    WidthRequest="30">
                    <forms:SvgCachedImage.GestureRecognizers>
                        <TapGestureRecognizer Command="{Binding CloseAllCommand}" CommandParameter="emptyValue" />
                    </forms:SvgCachedImage.GestureRecognizers>
                </forms:SvgCachedImage>
            </StackLayout>
        </ContentView>

您可以看到更多此错误here

还有一些对您有用的documentation

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。