We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Cell style: set Underlined text

Good evening,
Is possible to set a Underline FontStyle in a WPF SFDatagrid cell ?
I'm able to set FontWeight, FontStyle , ... but I'm not able find the Underline style. 

Thanks and Regards
Sauro

<Syncfusion:GridTemplateColumn Width="75" MappingName="LapValueDataDrvList[0].LapValueData" TextAlignment="Right" >
<Syncfusion:GridTemplateColumn.CellStyle>
 <Style TargetType="Syncfusion:GridCell">
                     <Style.Triggers>
                                <DataTrigger Binding="{Binding Path=ValueXYZ}" Value="1">
                                    <Setter Property="FontStyle" Value="Italic" />      <!-- this works fine -->
                                    <Setter Property="FontStyle" Value="Underline" />      <!-- It doesn't exist -->
                                </DataTrigger>
                      </Style.Triggers>
 </Style>
</Syncfusion:GridTemplateColumn.CellStyle>
 <Syncfusion:GridTemplateColumn.CellTemplate>
                        <DataTemplate>
                         ................
                        </DataTemplate>
</Syncfusion:GridTemplateColumn.CellTemplate>                         
 </Syncfusion:GridTemplateColumn>

3 Replies

JN Jayaleshwari N Syncfusion Team January 10, 2019 12:11 PM UTC

Hi Sauro,  
  
Thanks for contacting Syncfusion Support.  
  
We have analyzed your query “Underline not work with CellStyle” from our side. You can able to set underline for GridColumns text by using GridColumn.TextDecoration property. But it will not work for GridTemplateColumn. And we have internally used the DisplayElement as a content control for GridTemplateColumn, and the cell template loaded content  is added as a child of the content control and it will be showing on the UI.   
  
You can achieve your requirement Underline text for TextBlock by using the below code snippets.  
  
<syncfusion:GridTemplateColumn HeaderText="Order ID TEMP" MappingName="OrderID">  
    <syncfusion:GridTemplateColumn.CellTemplate>  
        <DataTemplate>  
            <TextBlock Text="{Binding OrderID}" >  
                <TextBlock.Style>  
                    <Style>  
                        <Style.Triggers>  
                            <DataTrigger Binding="{Binding Path=OrderID}" Value="1000">  
                                <Setter Property="TextBlock.FontStyle" Value="Italic" />  
                                <Setter Property="TextBlock.TextDecorations" Value="Underline"/>  
                            </DataTrigger>  
                        </Style.Triggers>  
                    </Style>  
                </TextBlock.Style>  
            </TextBlock>  
        </DataTemplate>  
    </syncfusion:GridTemplateColumn.CellTemplate>  
</syncfusion:GridTemplateColumn>  
 
We have attached the sample for your reference and you can download the same from the following location. 
  
you can refer the following user guide documentation for TextDecorations property 
  
Regard,  
Jayaleshwari N. 



SR Sauro Rossi January 10, 2019 03:58 PM UTC

Hi Jayaleshwari,
Thanks for your answer. Suggested approach works perfectly in my scenario.

Regard,
Sauro


JN Jayaleshwari N Syncfusion Team January 11, 2019 10:15 AM UTC

Hi Sauro, 
 
Thanks for the update. Please get in touch if you would require for further assistance. 
 
Regards, 
Jayaleshwari N. 


Loader.
Live Chat Icon For mobile
Up arrow icon