【问题标题】:Cannot set Content More than once xaml不能多次设置内容 xaml
【发布时间】:2020-05-30 08:49:51
【问题描述】:

我正在使用 Xamarin 和 xaml 来定义我的视图。我收到了一个我不理解的错误。

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
             xmlns:telerikDataControls="clr-namespace:Telerik.XamarinForms.DataControls;assembly=Telerik.XamarinForms.DataControls"
xmlns:telerikListView="clr-namespace:Telerik.XamarinForms.DataControls.ListView;assembly=Telerik.XamarinForms.DataControls"
              xmlns:telerikPrimitives="clr-namespace:Telerik.XamarinForms.Primitives;assembly=Telerik.XamarinForms.Primitives"
xmlns:telerikInput="clr-namespace:Telerik.XamarinForms.Input;assembly=Telerik.XamarinForms.Input" 
              xmlns:vm="clr-namespace:WMS.ViewModels"

             x:Class="Views.HomePage">
    <ContentPage.Content>

        <ScrollView>
            <Frame x:Name="reprint" Padding="40" IsClippedToBounds="False"   CornerRadius="4">
                <telerikPrimitives:RadBorder BorderThickness="8" CornerRadius="10">

                    <StackLayout>

                        <Label Text=" Label"></Label>
                        <Label Text="Allows the User to reprint a label."></Label>

                        <telerikInput:RadButton BackgroundColor="#343C41" TextColor="White" Text="Label Reprint" x:Name="btnLabelReprint" Clicked="BtnLabelReprint_Clicked">

                        </telerikInput:RadButton>
                    </StackLayout>

                </telerikPrimitives:RadBorder>




            </Frame>
            <Frame x:Name="warehouseTransferr" Padding="40"    CornerRadius="4">
                <telerikPrimitives:RadBorder BorderThickness="8" CornerRadius="10">

                    <StackLayout>

                        <Label Text="Ware House Transfer"></Label>
                        <Label Text="Allows users to transfer from warehouse to waehouse"></Label>

                    <telerikInput:RadButton BackgroundColor="#343C41" TextColor="White" Text="Warehouse Transfer" x:Name="btnWarehouseTransfe" Clicked="BtnWarehouseTransfe_Clicked">

                            </telerikInput:RadButton>
                    </StackLayout>

                </telerikPrimitives:RadBorder>




            </Frame>
        </ScrollView>
    </ContentPage.Content>
</ContentPage>

严重性代码描述项目文件行抑制状态 错误 XLS0501 多次设置属性“内容”。 HomePage.xaml 36

【问题讨论】:

    标签: xaml xamarin xamarin.forms xamarin.android


    【解决方案1】:

    一个 ScrollView 不能有多个子级,因此错误定义内容不止一次。

    因此,要解决此问题,您可以将内容封装在 StackLayout 中:

      <ScrollView>
        <StackLayout>
                <Frame x:Name="reprint" Padding="40" IsClippedToBounds="False"   CornerRadius="4">
                    <telerikPrimitives:RadBorder BorderThickness="8" CornerRadius="10">
    
                        <StackLayout>
    
                            <Label Text=" Label"></Label>
                            <Label Text="Allows the User to reprint a label."></Label>
    
                            <telerikInput:RadButton BackgroundColor="#343C41" TextColor="White" Text="Label Reprint" x:Name="btnLabelReprint" Clicked="BtnLabelReprint_Clicked">
    
                            </telerikInput:RadButton>
                        </StackLayout>
    
                    </telerikPrimitives:RadBorder>
                </Frame>
                <Frame x:Name="warehouseTransferr" Padding="40"    CornerRadius="4">
                    <telerikPrimitives:RadBorder BorderThickness="8" CornerRadius="10">
    
                        <StackLayout>
    
                            <Label Text="Ware House Transfer"></Label>
                            <Label Text="Allows users to transfer from warehouse to waehouse"></Label>
    
                        <telerikInput:RadButton BackgroundColor="#343C41" TextColor="White" Text="Warehouse Transfer" x:Name="btnWarehouseTransfe" Clicked="BtnWarehouseTransfe_Clicked">
    
                                </telerikInput:RadButton>
                        </StackLayout>
    
                    </telerikPrimitives:RadBorder>
                </Frame>
            </StackLayout>
        </ScrollView>
    

    【讨论】:

    • 只是需要第二双眼睛,以为我可能遗漏了一堆感谢表格,从过去开始已经有很长的路要走,但有些错误消息没有帮助。
    • 确实这条消息有点笼统。但很高兴我能帮忙:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多