views:

302

answers:

1

Is it possible?

I have a listview with several gridviewcolumns. The last column has a dynamic header. I dont know what the column header will be at design time. It's actually a number I want to display as a string.

    <GridViewColumn Header="{Binding Path=SomeValue}" 
                    DisplayMemberBinding="{Binding Path=OtherValue}"/>

This doesn't seem to work. The data will bind fine just the header remains blank. Stepping through the code and it doesn't even break on the SomeValue property.

+2  A: 

I think your problem is the source of the "SomeValue" property. If you are binding to a list of objects, it wouldn't make sense to have the header determined by a property on that object, because then you could have a different header for every object. Essentially what you are saying is "Bind the header of the column to the 'SomeValue' property which lives on the same object that my 'OtherValue' property does." The "SomeValue" needs to come from a different source other than the list your grid item is bound to. You need to either set the "RelativeSource" or the "ElementName" property in the binding.

Micah
It's obvious now you've pointed that out. Thankyou!!!
Crippeoblade