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

Does the DataGridTemplateColumn have an equivalent to CellEditingTemplate in UWP Toolkit?

2 Answers 297 Views
DataGrid
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 21 Sep 2018, 10:38 PM

Is there a way to set the DataGridTemplateColumn for a different template when it is in Edit Mode.   The UWP Toolkit DataGrid has CellTemplate and CellEditingTemplate to have different templates for the normal and editing mode.  For example I have used TextBlock for normal mode and TextBox for editing mode in UWP Toolkit datagrid.  

I do this so I can wrap the text in the cell.  Neither the Telerik DataGrid or the UWP Toolkit has a wrap option in the TextColumn (that I can find)

2 Answers, 1 is accepted

Sort by
0
Lance | Manager Technical Support
Telerik team
answered on 24 Sep 2018, 07:16 PM
Hello Robert,

The DataGrid styling works by allowing you to set the style of specific elements used by that column. You can see these by start typing in 'Style' and let IntelliSense populate the list.

Here's a screenshot of the styles available for a DataGridTextColumn, the one you're asking about is the CellEditorStyle.




For the DataGridTextColumn the style should target TextBox as this is the editor for a string property type, which will allow you to set the properties you want to.

<grid:DataGridTextColumn.CellEditorStyle>
    <Style TargetType="TextBox">
        <Setter Property="PropertyYouWantToSet"
            Value="ValueYouWantForThatProperty"/>
    </Style>
</grid:DataGridTextColumn.CellEditorStyle>

For text wrapping, a UWP TextBox uses a property named "TextWrapping". Here's a style with that set:

<Style TargetType="TextBox">
    <Setter Property="TextWrapping" Value="Wrap"/>
</Style>

One thing to keep in mind that the editor will not always enforce it;s style on the row itself. For example, if you open the editor and have wrapping enabled for a really long string, then it's not going to enforce this on a parent.

You might want to also try other property settings like minimum height

<grid:DataGridTextColumn.CellEditorStyle>
    <Style TargetType="TextBox">
        <Setter Property="TextWrapping" Value="Wrap"/>
        <Setter Property="MinHeight"  Value="200" />
    </Style>
</grid:DataGridTextColumn.CellEditorStyle>

I hope this helps clarify this case, but also help you discover other features.

Regards,
Lance | Tech Support Engineer, Sr.
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Robert
Top achievements
Rank 1
answered on 24 Sep 2018, 11:45 PM
Thanks for the reply.  I'll give the suggestions a try.
Tags
DataGrid
Asked by
Robert
Top achievements
Rank 1
Answers by
Lance | Manager Technical Support
Telerik team
Robert
Top achievements
Rank 1
Share this question
or