c# - 在 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
是我需要在特定条件下隐藏在所有列表视图项中的框架,我该如何实现?请帮我。
解决方案
只需将IsVisible
您的属性绑定frmHire
到ItemsSource
.
托管ObservableCollection
or的父视图模型List
只需要遍历项目并相应地设置条件。
推荐阅读
- html - 为什么我们在 css 中的无序列表中的列表项中添加图像后没有得到要点?
- python - 从印度的形状文件中为特定状态创建叶绿素
- php - Magento 1.9.3 未捕获的错误:在布尔 Payment/Model/Observer.php 上调用成员函数 getMethodInstance()
- ios - Xamarin-iOS 崩溃:自 iOS 13 以来,只要打开语音,我们的应用程序就会崩溃
- powershell - 如果文件夹的任何子文件夹中有 csv 文件,如何不删除文件夹
- azure-data-explorer - Kusto 中的 EXECUTE 或 sp_executesql 命令
- php - 如何删除重复的用户详细信息
- vue.js - 修改 v-tab Vuetify 中上一个/下一个箭头的行为
- python - 为什么 numpy 的 as_strided 用(默认)strides=None 改变数组步幅?
- android - Corner radius property missing on MaterialButton after update to Material 1.2.0