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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Does not apply style from App.xaml

Thread ID:

Created:

Updated:

Platform:

Replies:

127342 Nov 9,2016 12:33 PM UTC Nov 14,2016 11:56 AM UTC Xamarin.Forms 3
loading
Tags: SfDataGrid
Maheshkumar
Asked On November 9, 2016 12:33 PM UTC

Hi,

I have my style define in App.xaml like folowing

 <Style TargetType="Label" Class="HeaderLabel">
        <Setter Property="TextColor" Value="{StaticResource LabelDarkColor}"></Setter>
        <Setter Property="FontSize" Value="Large"></Setter>
        <Setter Property="FontFamily">
          <OnPlatform x:TypeArguments="x:String">
            <OnPlatform.Android>GeosansLight.ttf#GeosansLight</OnPlatform.Android>
            <OnPlatform.iOS>GeosansLight.ttf</OnPlatform.iOS>
          </OnPlatform>
        </Setter>
 </Style>

but it is not getting applied to any to lable placed with in SfDataGrid.

Regards,
Mahesh



Ashok N [Syncfusion]
Replied On November 10, 2016 12:35 PM UTC

Hi Maheshkumar, 

Thanks for contacting Syncfusion support. 

We have analyzed your query and you can customize the Grid style by customizing GridCell style and bind the style into GridColumn.CellStyle property as in the below code example. 
App.xaml: 
<Application.Resources> 
  <ResourceDictionary> 
    <Style TargetType="sfgrid:GridCell" x:Key="gridCellStyle"> 
      <Setter Property="BackgroundColor" Value="Green"></Setter> 
      <Setter Property="Foreground" Value="Red"></Setter> 
    </Style> 
  </ResourceDictionary> 
</Application.Resources> 
                        
ContentPage.xaml 
<sfgrid:SfDataGrid.Columns x:TypeArguments="sfgrid:Columns"> 
  <sfgrid:GridTextColumn MappingName="OrderID" CellStyle="{StaticResource gridCellStyle}"> 
  </sfgrid:GridTextColumn> 
</sfgrid:SfDataGrid.Columns> 


Also customize the style by overriding DataGridStyle and assigning it to the SfDataGrid.GridStyle property. Please refer the below UG link to get more information about SfDataGrid.GridStyle. 

Regards, 
Ashok 


Maheshkumar
Replied On November 11, 2016 11:42 PM UTC

Hi Ashok, 

That's not what I want. Please see below code, I have a template column

<syncfusion:GridTemplateColumn MappingName="id" >
              <syncfusion:GridTemplateColumn.CellTemplate>
                <DataTemplate>
                    <Label Text="{Binding NoticeDate, StringFormat='{0:dd/MM/yyyy}'}}"  Margin="10, 0, 0, 0"  StyleClass="HeaderLabel"/>
                </DataTemplate>
              </syncfusion:GridTemplateColumn.CellTemplate>
</syncfusion:GridTemplateColumn>

 
See above StyleClass applied to lable is not getting applied.

Regards,
Mahesh

Ashok N [Syncfusion]
Replied On November 14, 2016 11:56 AM UTC

Hi MaheshKumar, 

 
We have checked your query and you can achieve your requirement by binding Style to Label, as in the below code example  
App.Xaml: 
<Application.Resources> 
  <ResourceDictionary> 
   <Style x:Key="labelStyle" TargetType="Label" > 
    <Setter Property="TextColor" Value="Red"></Setter> 
    <Setter Property="FontSize" Value="Large"></Setter> 
   </Style> 
  </ResourceDictionary> 
</Application.Resources>
 

 
Main page: 
<sfgrid:GridTemplateColumn MappingName="ShippingDate" > 
  <sfgrid:GridTemplateColumn.CellTemplate> 
   <DataTemplate> 
    <Label Text="{Binding ShippingDate, StringFormat='{0:dd/MM/yyyy}'}}" Style="{StaticResource labelStyle}"/> 
   </DataTemplate> 
  </sfgrid:GridTemplateColumn.CellTemplate> 
</sfgrid:GridTemplateColumn>
 

 
Regards, 
Ashok 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;