如何解决XAML是否可以在Style中绑定数组的索引?
可以绑定数组的索引,例如:
<Style x:Key="NameButtonStyle" TargetType="Button">
<Setter Property="Visibility" Value="{Binding Array[{Binding custom property index}]}/>
</Style>
解决方法
仅当“ index”由诸如1
之类的常量指定时:
<Style x:Key="NameButtonStyle" TargetType="Button">
<Setter Property="Visibility" Value="{Binding Array[1]}/>
</Style>
您不能用运行时解析的动态值替换上例中的1
。如果需要此功能,则必须使用转换器或公开返回Array[x]
的属性,其中x
代表动态值。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。