I have two columns in the GridView. I want one column's text(including header) is on the left, the other column is on the right.
<
telerik:GridViewDataColumn
Header
=
"Content"
DataMemberBinding
=
"{Binding Content}"
TextAlignment
=
"Left"
HeaderTextAlignmemt
=
"Left"
/>
<
telerik:GridViewDataColumn
Header
=
"Date"
DataMemberBinding
=
"{Binding Date}"
TextAlignment
=
"Right"
HeaderTextAlignmemt
=
"Right"
/>
But it is not working, two columns are always aligned to the left. Then I used Visual Tree to check the properties. For the GridViewCell.
PART_CellBorder [Border]
Background_Over [Border]
Background_Selected[Border] etc
The default HorizontalAlignment is Stretch. I am not sure how to set the styles for the alignment.
Thanks.
11 Answers, 1 is accepted

What you can use for your scenario in order to pin the columns to the left/right is to use the LeftFrozenColumnCount/RightFrozenColumnCount property of the RadGridView. These properties are further described in the Frozen Columns help article in our documentation. In your case, check the following code snippet.
<
telerik:RadGridView
ItemsSource
=
"{Binding Data}"
AutoGenerateColumns
=
"False"
LeftFrozenColumnCount
=
"1"
RightFrozenColumnCount
=
"1"
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding Content}"
TextAlignment
=
"Left"
HeaderTextAlignment
=
"Left"
/>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding Date}"
TextAlignment
=
"Right"
HeaderTextAlignment
=
"Right"
/>
</
telerik:RadGridView.Columns
>
</
telerik:RadGridView
>
Hope this functionality will work for your scenario.
Regards,
Dinko
Progress Telerik

I can't find it in RadGridView. It is in GridViewDataControl
My version is 2016
The LeftFrozenColumnCount and RightFrozenColumnCount properties of the RadGridView control are introduced with the R1 2018 version of our controls. I recommend you to download the latest version of our controls so you can take advantage of the latest features, bug fixes, and new controls.
Regards,
Dinko
Progress Telerik

I've attached a small sample project where setting the TextAlignment and HeaderTextAlignment of the columns to Left and Right accordingly and setting the width of those columns to * seems to result in the desired layout at my end.
Could you please have a look and let me know whether this is indeed the case? If it is, please specify how this setup differs from the one you have at your end. If not, please specify your exact requirements so that I can further assist you.
I look forward to your reply.
Regards,
Dilyan Traykov
Progress Telerik

My case is similar with this.
Say we have the main view
<
ScrollViewer
Grid.Row
=
"5"
VerticalScrollBarVisibility
=
"Auto"
HorizontalScrollBarVisibility
=
"Auto"
>
<
ContentControl
Grid.Row
=
"5"
Background
=
"Transparent"
Focusable
=
"False"
Margin
=
"0,5,0,0"
Content
=
"{Binding CurrentSection}"
ContentTemplateSelector="{StaticResource templateSelector}/>
</
ScrollViewer
>
The RadGridView is inside in the another view CurrentSection. If I set the Width = * for the two columns, then the width becomes very big(infinity). So it is not alignment issue, perhaps something else. Maybe Virtualization issue. I saw that there is a tip and trick.
I have spent several days on it and no clue.
Thanks.

And more in the View CurrentSection, the Grid code likes.
<
Grid
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"auto"
/>
<
RowDefinition
Height
=
"*"
/>
</
Grid.RowDefinitions
>
<
Somecontrol
Grid.Row
=
"0"
/>
<
telerik:RadGridView
Grid.Row
=
"0"
Style
=
"{StaticResource MyStyle}"
RowStyle
=
"{StaticResource SomeRowStyle}"
CanUserDeleteRows
=
"False"
IsReadOnly
=
"True"
AutoGenerateColumns
=
"False"
ShowGroupPanel
=
"False"
IsFilteringAllowed
=
"False"
CanUserReorderColumns
=
"False"
RowIndicatorVisibility
=
"Collapsed"
EnableRowVirtualization
=
"True"
EnableColumnVirtualization
=
"True"
FrozenColumnCount
=
"2"
SelectionUnit
=
"FullRow"
SelectionMode
=
"Extended"
AlternationCount
=
"2"
AlternateRowBackground
=
"LightSteelBlue"
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding FirstName}"
Header
=
"First Name"
HeaderCellStyle
=
"{StaticResource GridViewHeaderCellStyle}"
TextAlignment
=
"Left"
HeaderTextAligntment
=
"Left"
CellStyle
=
"{StaticResource SomeCellStyle}"
Width
=
"*"
/>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding LastName}"
Header
=
"Last Name"
HeaderCellStyle
=
"{StaticResource GridViewHeaderCellStyle}"
TextAlignment
=
"Right"
HeaderTextAligntment
=
"Right"
CellStyle
=
"{StaticResource SomeCellStyle}"
Width
=
"*"
/>
</
telerik:RadGridView.Columns
>
</
telerik:RadGridView
>
</
Grid
>

Sorry for some edit error,should remove the following lines.
FrozenColumnCount="2"
SelectionUnit="FullRow"
SelectionMode="Extended"

Resolved it. The case is actually similar with this.
The problem you see is because as the Datagrid is inside a ScrollViewer, it has virtually infinite space to expand,so it can't calculate widths.
<
RadGridView
AutoGenerateColumns
=
"False"
ColumnWidth
=
"*"
Width="{Binding RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type ScrollViewer}},
Path
=
ViewportWidth
}">
Indeed, the result you described is expected when using a ScrollViewer. In fact, our Tips and Tricks article suggests not to place the control in such containers as apart from the issue you've come across, the control's virtualization mechanism turns off which results in poor performance.
Nonetheless, I'm glad to hear that you have resolved your issue. If you require any further assistance, please let me know.
Regards,
Dilyan Traykov
Progress Telerik