tags:

views:

88

answers:

1

Ok, the problem is that I have a few GridViewColumns, which don't implement a Name property, but, I can always of course set the x:Name property to them. How ever, I need to get them by this name on code, sort of like

foreach(GridViewColumn column in this.ColumnCollection)
{
    if(column.(x:Name Property) == "columnName")
        return column
}

return null

I did solve this by using a custom column "NamedGridViewColumn" that inherits from GridViewColumn and implements a Name property, but it would still be interesting to know how to get the x:Name on code.

Thanks!

+1  A: 

I think

column.GetValue(NameProperty).ToString() == "columnName"

should do the trick.

chrischu
Didn't work, it returns an emptry string ("")
Carlo
Mhh thats strange. It worked on my machine (admittedly not with GridViewColumns but with a TextBlock).
chrischu