【问题标题】:XAML there's the way to binding the array's index in a Style? [duplicate]XAML 有没有将数组的索引绑定到样式中的方法? [复制]
【发布时间】:2020-12-07 19:45:58
【问题描述】:

可以绑定数组的索引,例如:

<Style x:Key="NameButtonStyle" TargetType="Button">
    <Setter Property="Visibility" Value="{Binding Array[{Binding custom property index}]}/>
</Style>

【问题讨论】:

  • 除了链接。您也可以使用多重绑定和多重转换器。

标签: wpf xaml binding styles


【解决方案1】:

仅当“索引”由常量指定时,例如 1:

<Style x:Key="NameButtonStyle" TargetType="Button">
    <Setter Property="Visibility" Value="{Binding Array[1]}/>
</Style>

您不能将上面示例中的1 替换为在运行时解析的动态值。如果需要,您必须使用转换器或公开返回 Array[x] 的属性,其中 x 表示动态值。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-10-26
    • 2017-10-02
    • 1970-01-01
    • 2010-09-21
    • 2014-08-31
    • 2018-06-14
    • 2017-12-10
    • 2010-09-21
    相关资源
    最近更新 更多