我使用下面的代码绑定(bind)到 ColumnSection
类的 Depth
属性。我正在使用 LengthConverter
返回任意结果。
<GridViewColumn Header="Depth"
DisplayMemberBinding="{Binding Path= Depth, Converter={StaticResource LengthConverter}}"
Width="60" />
现在如果我想绑定(bind)到 ColumnSection
类本身怎么办?然后我将使用转换器返回宽度/深度比率并将其显示为结果。我该怎么做?
最佳答案
您使用“.”路径:
DisplayMemberBinding="{Binding Path=., Converter={...}}"
“。”映射到当前数据上下文。
事实证明,您甚至可以执行这些操作,因为默认 路径是“.”:
DisplayMemberBinding="{Binding Converter={...}}"
DisplayMemberBinding="{Binding}" //No converter obviously
我最喜欢我的原作,因为它最直白易懂。
关于c# - 如何在 WPF C# 中绑定(bind)到类本身,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27113626/