I have an editable RadGridView with set column widths. When the user clicks a cell to edit its contents, the editing TextBox appears to be much more narrow than the width of its column. How can I change this so that the TextBox stretches to the column width?
I tried using a template for the cell but this prevented the cell/row validation from working:
Then I tried setting the CellStyle property, but this had no effect:
I tried using a template for the cell but this prevented the cell/row validation from working:
<
DataTemplate
x:Name
=
"editCellTemplate"
>
<
Grid
>
<
TextBox
MaxLength
=
"100"
Margin
=
"5,3"
Width="{Binding ActualWidth,
RelativeSource={RelativeSource
Mode
=
FindAncestor
,
AncestorType={x:Type telerik:GridViewCell}}}"
Text
=
"{Binding Label, Mode=TwoWay}"
/>
</
Grid
>
</
DataTemplate
>
<
telerik:RadGridView
Margin
=
"10"
MinHeight
=
"300"
RowHeight
=
"30"
HorizontalAlignment
=
"Left"
VerticalAlignment
=
"Top"
AutoGenerateColumns
=
"False"
IsFilteringAllowed
=
"False"
CanUserInsertRows
=
"True"
CanUserDeleteRows
=
"False"
CanUserFreezeColumns
=
"False"
CanUserReorderColumns
=
"False"
ShowGroupPanel
=
"False"
ShowInsertRow
=
"True"
ItemsSource
=
"{Binding SourceView, Mode=OneWay}"
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewDataColumn
x:Name
=
"Label"
Header
=
"Label"
Width
=
"300"
DataMemberBinding
=
"{Binding Label, Mode=TwoWay}"
CellEditTemplate
=
"editCellTemplate"
/>
<
telerik:GridViewCheckBoxColumn
x:Name
=
"Inactive"
Header
=
"Inactive"
DataMemberBinding
=
"{Binding IsDeleted, Mode=TwoWay}"
Width
=
"Auto"
/>
</
telerik:RadGridView.Columns
>
</
telerik:RadGridView
>
Then I tried setting the CellStyle property, but this had no effect:
<
telerik:GridViewDataColumn.CellStyle
>
<
Style
>
<
Setter
Property
=
"TextBox.MaxLength"
Value
=
"100"
/>
<
Setter
Property
=
"TextBox.Margin"
Value
=
"5"
/>
<
Setter
Property
=
"TextBox.Width"
Value="{Binding ActualWidth, RelativeSource={RelativeSource
Mode
=
FindAncestor
, AncestorType={x:Type telerik:GridViewCell}}}" />
</
Style
>
</
telerik:GridViewDataColumn.CellStyle
>