【发布时间】:2018-11-15 01:10:30
【问题描述】:
我正在通过 MVVM 方法使用 Xamarin Forms,它运行良好。
我需要向现有 ListView 添加功能,以便在绑定值为某个值时显示文本。
这里是生成描述的单元格
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout>
<Label Text="{Binding Description}" x:Name="lblDescription"
Style="{DynamicResource ListItemTextStyle}" />
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
有没有什么方法基本上只显示标签是以下功能是真的(这可能在视图模型或代码后面)例如:
private bool IsDescriptionOk(string description)
{
//Look up description possibly in another lookup list
}
id 想将可见的绑定到方法上,比如:
Visible="{Binding IsDescriptionOk}"
但由于它在列表视图中,如果有意义,id 是否需要传入项目索引?
【问题讨论】:
-
为什么需要传递索引?为什么不能只根据 Description 属性的长度返回一个布尔值?
-
这只是一个例子,我想查找实际描述,例如:如果描述是“在线”,则返回 false,如果描述是“处理中”,则返回 true 等。 ...
标签: listview xamarin.forms binding