0

I am trying to dynamically build columns in C#, but I am not sure how to convert this to C#

<xcdg:Column FieldName="Name" 
             Title="Name"
             DisplayMemberBinding="{Binding}"
             CellContentTemplate="{StaticResource InputManagerNameCellTemplate}"
             AllowAutoFilter="False"/>

I know how to convert all of that BUT the DisplayMemberBinding part.

Thanks.

akjoshi
  • 15,374
  • 13
  • 103
  • 121
g.t.w.d
  • 601
  • 1
  • 10
  • 30

1 Answers1

2

Try this:

new Binding()
{
    Path = new PropertyPath(FrameworkElement.DataContextProperty),
    RelativeSource = new RelativeSource(RelativeSourceMode.Self)
}

Empty Binding in XAML is a shortcut to bind to DataContext on the same element.

akjoshi
  • 15,374
  • 13
  • 103
  • 121
Stipo
  • 4,566
  • 1
  • 21
  • 37