【发布时间】:2019-03-07 16:54:31
【问题描述】:
我的 xaml 中有一个分组的 listView。
这是 listView 对象:
附件:
public string TCPNumber { get; set; }
public string AttachmentName { get; set; }
public int FileType { get; set; }
这些组是基于 FileType 值的 X 和 Y 名称。 每个列表项显示上述 3 项的值。 我想隐藏文件类型值为 2 的 Y 组列表项中的 TCPNumber 项。
下面是我的 xaml:
<ContentPage.Resources>
<ResourceDictionary>
<converter:TCPGridVisibleConverter x:Key="TCPGridVisible" />
</ResourceDictionary>
<ContentPage.Resources>
<ListView x:Name="lvTCPs" HasUnevenRows="True"
<ListView.GroupHeaderTemplate>
<DataTemplate>
<ViewCell>
<StackLayout>
<Label Text="{Binding Key}"/>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.GroupHeaderTemplate>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="{Binding Path=FileType, Source={x:Reference
Name=AttachmentsTabPage}, Converter={StaticResource TCPGridVisible}}">
</RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"></ColumnDefinition>
<ColumnDefinition Width="2*"></ColumnDefinition>
</Grid.ColumnDefinitions>
</ListView>
这是我试图隐藏 ViewCell 的第一行的方式,但没有成功。 有什么帮助吗?
【问题讨论】:
-
如果你想隐藏一整行,我认为首先不将它包含在 ItemsSource 中会更容易
-
我只想在 listitem 的 FileType 值为 2 时隐藏该行,否则我需要填充该行
-
那么在构建 ItemsSource 时为什么不过滤掉 FileType=2?
-
实际上我的要求不是删除列表项。我想删除/隐藏 fileType 值为 2 的每个列表项的第一行。如何使用 itemsource 过滤掉
-
您确实需要编辑您的问题以澄清您的意思是 ViewCell Grid 的行,而不是 ListView 的行
标签: listview xamarin mvvm xamarin.forms