如何修复“属性设置多次”?

时间:2019-10-28 07:21:22

标签: c# xamarin xamarin.forms

在列表视图中,当我扩展列表视图时,我想显示给许多控件,但是当我将Isvisible属性分配给标签时,出现此错误“属性“ text”被显示多次”

 <?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"
                 x:Class="CpoLogin.MainPage">

            <ListView ItemsSource="{Binding Complains}"
                      HasUnevenRows="True"
                      Margin="40,80"
                      ItemTapped="ListView_ItemTapped">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>
                            <StackLayout>
                            <Label Text="{Binding ComplainsTitle}"/>
                            <Label Text="Caller CNIC: 4220142488449"/>
                            <Label Text="Complaint Type: Emergency"/>
                            <Label Text="Notes: Gulshan-e-Iqal,Karachi"/>
                            <Label Text="Criminals Involved: 2"/>
                            <Label Text="Dead Count: 2"/>
                            <Label Text="Sub Type: Murder"/>
                            <Label Text="Criminal Appearance: 2"/>
                            <Label Text="Wounded Count: 2"/>
                            <Label Text="Vehicle Used: 2"
                                   IsVisible="{Binding IsVisible}/>



                            <Button Text="Details"
                                    IsVisible="{Binding IsVisible}"/>

                        </StackLayout>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>

            </ListView>

    </ContentPage>

2 个答案:

答案 0 :(得分:3)

@Aashir Khan

请替换以下代码

<Label Text="Vehicle Used: 2"
       IsVisible="{Binding IsVisible}" />

您忘记了双引号,如果有帮助,请检查并接受答案。

答案 1 :(得分:0)

使用内容而不是文本作为按钮。