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

Wrapping for GridViewCell. Telerik for WPF.

3 Answers 642 Views
GridView
This is a migrated thread and some comments may be shown as answers.
NATALIA
Top achievements
Rank 1
NATALIA asked on 13 Dec 2019, 12:11 PM

Hi!
I need to configure textBlock wrapping  in a custom style for GridViewCell in GridViewDataColumn. How to do this?

Style:

<Style x:Key="GridViewCellWrapping" TargetType="TextBlock">

        <Setter Property="TextWrapping" Value="Wrap"/>

</Style>

Use style:

<telerik:RadTreeListView.Columns>

<telerik:GridViewDataColumn Width="*" CellStyle="{StaticResource GridViewCellWrapping}"    

  Header="{x:Static strRes:Resources.txtSpecification}" DataMemberBinding="{Binding Description}"/>

</telerik:RadTreeListView.Columns>

 

And it doesn't work.

 

3 Answers, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 18 Dec 2019, 09:23 AM

Hello Natalia,

Thank you for the provided code snippet.

You can try setting the TextWrapping property of the GridViewDataColumn. This property will be applied to all cells inside the column.

<telerik:GridViewDataColumn Width="*" CellStyle="{StaticResource GridViewCellWrapping}" Header="{x:Static strRes:Resources.txtSpecification}" DataMemberBinding="{Binding Description}" TextWrapping="Wrap"/>

Give this property a try and let me know if it works for you.

Regards,
Dinko
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
NATALIA
Top achievements
Rank 1
answered on 18 Dec 2019, 09:40 AM
Thanks for the answer.
But we would like to create a style (onсe) for the text cell in GridViewDataColumn, where we can made TextWrapping and customize the vertical and horizontal position too. And then apply this style to all text cells in GridViewDataColumn. Can we somehow do this by setting the style in the cellstyle for GridViewDataColumn?
0
Dinko | Tech Support Engineer
Telerik team
answered on 20 Dec 2019, 11:56 AM

Hello Natalia,

Another approach that you could try is to set the CellTemplate property of the GridViewDataColumn. In a few words, you can create custom DataTemplate and add TextBlock inside. Then you can set its properties like TextWrapping.

<telerik:GridViewDataColumn DataMemberBinding="{Binding Description}"  >
    <telerik:GridViewDataColumn.CellTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding Description}" TextWrapping="Wrap" HorizontalAlignment="Right"/>
        </DataTemplate>
    </telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>

Regards,
Dinko
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
NATALIA
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
NATALIA
Top achievements
Rank 1
Share this question
or