首页 > 解决方案 > 在 xamarin 表单列表视图中查找和元素

问题描述

我有 xamarin.forms.listview 控件,其中有一些元素。此列表视图将动态填充。现在在特定条件下,我需要在列表视图中隐藏一个元素,我怎样才能找到它并隐藏它?

<ListView x:Name="lstBids" Margin="0" HasUnevenRows="True">
    <ListView.ItemTemplate >
        <DataTemplate>
            <ViewCell>
                <Frame Margin="0,0,0,5" Padding="0" BackgroundColor="White">
                    <StackLayout Orientation="Vertical">
                        <Label Style="{StaticResource Medium}" Margin="10" HorizontalOptions="StartAndExpand" x:Name="lblComments" Text="{Binding Comments}"></Label>
                                <Frame x:Name="frmHire" BackgroundColor="{StaticResource base}" Padding="10,5" CornerRadius="5" HasShadow="False">
                                    <Label Text="Hire" Style="{StaticResource MediumWhite}"></Label>
                                    <Frame.GestureRecognizers>
                                        <TapGestureRecognizer Tapped="Hire_Clicked"></TapGestureRecognizer>
                                    </Frame.GestureRecognizers>
                                </Frame>
                            <Label Style="{StaticResource SmallGray}" HorizontalOptions="EndAndExpand"  Margin="0,0,10,0"  x:Name="lblDate" Text="{Binding UpdatedDate, StringFormat='{0:MMMM dd, yyyy hh:mm tt}'}"></Label>
                    </StackLayout>
                </Frame>
            </ViewCell>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

frmHire是我需要在特定条件下隐藏在所有列表视图项中的框架,我该如何实现?请帮我。

标签: c#xamarin.forms

解决方案


只需将IsVisible您的属性绑定frmHireItemsSource.

托管ObservableCollectionor的父视图模型List只需要遍历项目并相应地设置条件。


推荐阅读