How to link yourself to the class itself in WPF C #
I am using the below code to bind to a property of a Depth
class ColumnSection
. And I use LengthConverter
to return an arbitrary result.
<GridViewColumn Header="Depth"
DisplayMemberBinding="{Binding Path= Depth, Converter={StaticResource LengthConverter}}"
Width="60" />
Now if I wanted to bind to a class ColumnSection
? Then I will use a converter to return the Width / Depth ratio and display it as a result. How can i do this?
+3
source to share
1 answer
You're using "." Way:
DisplayMemberBinding="{Binding Path=., Converter={...}}"
"" displays the current data context.
As it turns out, you can even do this since the default path is ".":
DisplayMemberBinding="{Binding Converter={...}}"
DisplayMemberBinding="{Binding}" //No converter obviously
I like my original best because it is the most explicit and understandable.
+6
source to share