【问题标题】:XAML Binding index operatorXAML 绑定索引运算符
【发布时间】:2016-03-08 10:34:30
【问题描述】:

是否可以将 [] 运算符中的值与包含数组本身的数据上下文不同的数据上下文绑定?

我设法在我想用这个绑定绑定的元素中获得正确的索引:

Binding DataContext.INDEX_ID, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:UCIndexByClientKeyMeasure}}

INDEX_ID 给了我正确的整数

但是我不能让这个索引在另一个绑定中工作。我试过了:

Binding .[{Binding  DataContext.INDEX_ID,RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:UCIndexByClientKeyMeasure}}}]

当我传递一个 satic 值时,例如:

Binding .[10]

然后就可以了。

谢谢

【问题讨论】:

标签: c# wpf xaml


【解决方案1】:

MultiBinding 确实...谢谢

<MultiBinding Converter="{StaticResource clientIndexConverter}"
              StringFormat="N2">
    <Binding Path="DataContext.INDEX_ID"
             RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type local:UCIndexByClientKeyMeasure}}" />
    <Binding Path="." />
</MultiBinding>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-11-22
    • 2012-08-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-06
    • 2021-08-01
    相关资源
    最近更新 更多