This is a migrated thread and some comments may be shown as answers.

Binding CellTemplate properties to parent column's DataFormatString

1 Answer 339 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Marcus
Top achievements
Rank 1
Marcus asked on 03 Jun 2013, 01:23 PM
I have the following CellTemplate for a few columns in my RadGridView:

<DataTemplate x:Key="TextCell" DataType="telerik:GridViewCell">
        <TextBlock Text="{Binding Value,
                                  RelativeSource={RelativeSource FindAncestor,
                                                                 AncestorType={x:Type telerik:GridViewCell}}}"
                   TextAlignment="{Binding TextAlignment,
                                           RelativeSource={RelativeSource TemplatedParent}}"
                   TextTrimming="CharacterEllipsis"
                   TextWrapping="NoWrap" />
    </DataTemplate>

This is being applied correctly, but I need to access properties such as TextAlignment and DataFormatString that are set on the GridDataViewColumn for that cell.  As you can see I've tried to access via the TemplatedParent, but to no avail.  How can I access these properties, so I can use them within my template?

Thanks.

1 Answer, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 03 Jun 2013, 03:31 PM
Hello Marcus,

Actually, columns are not visual elements and you cannot bind directly to their properties in the cell as TemplatedParent. Each cell has Column property and you can get the values from it, but you cannot use bindings in this manner. 

Regards,
Maya
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Marcus
Top achievements
Rank 1
Answers by
Maya
Telerik team
Share this question
or