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

CellEditTemplate binding

1 Answer 193 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Henry
Top achievements
Rank 1
Henry asked on 23 Jan 2013, 08:33 PM
Hi

I have a question on using the CellEditTemplate which has a TextBox in RadGridView.

I have a RadGridView, one of its columns is created like this in cs file:

gvColumn = new GridViewDataColumn();
gvColumn.CellEditTemplate = (DataTemplate)grid.TryFindResource("TextBoxEditTemplate");
gvColumn.DataType = typeof(string);
gvColumn.DataMemberBinding = new Binding(...)

In xaml file I define the template like this:

<telerik:RadGridView.Resources>
                <DataTemplate x:Key="TextBoxEditTemplate">
                    <TextBox Text="{Binding RelativeSource={RelativeSource Self}, Path=DataMemberBinding.PropertyPath}"/>
                </DataTemplate>
...

but the 'Text' of this text box is not bound to content of the cell, they are sperated, when user tries to edit, the cell's content is not
in the TextBox, and vice versa.

Thanks.

Henry

1 Answer, 1 is accepted

Sort by
0
Henry
Top achievements
Rank 1
answered on 24 Jan 2013, 10:45 PM
I find the correct way to binding, it should be:

<TextBox Text="{Binding

RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:GridViewCell }}, Path=Value

}"/>

Thanks.

Henry
Tags
GridView
Asked by
Henry
Top achievements
Rank 1
Answers by
Henry
Top achievements
Rank 1
Share this question
or