【问题标题】:How to filter data in an array property for binding in xaml如何过滤数组属性中的数据以在 xaml 中绑定
【发布时间】:2015-11-24 21:56:20
【问题描述】:

我有一个带有以下字段的课程:

public byte[] myByteArray;

我在 ListView 中绑定数组的值:

<GridViewColumn DisplayMemberBinding="{Binding myByteArray[1]}" />
<GridViewColumn DisplayMemberBinding="{Binding myByteArray[2]}" />
...

当数组中的元素为零时,如何将条目留空?

Pseudocode: if(myByteArray[indexValue] == 0) display nothing in ListView

提前致谢,

【问题讨论】:

  • 为什么你的代码是 GridViewColumn 而你的伪代码是 ListView?
  • 我基于 ListView 的几个例子都是这样使用的,我不知道下划线的原因,但它就像我想要的那样工作。

标签: c# arrays xaml properties


【解决方案1】:

我可能在这里遗漏了一些东西,但是要将 ListView 设为空白,请将其设置为 null。

if(myByteArray[indexValue]==0)
   listView=null;

要将特定项目设为空白,请将该特定项目设置为空。比如

listView.Items.GetItemAt(index)=null;

【讨论】:

  • 我认为这会将整个 ListView 设置为空。我只希望该特定值空白。
  • 不幸的是它没有 - 我最终找到了另一种使用数据模板触发器的方法,无论如何感谢您的帮助。
猜你喜欢
  • 2011-06-12
  • 2015-06-11
  • 1970-01-01
  • 1970-01-01
  • 2014-08-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-03-20
相关资源
最近更新 更多