I have a sfDataGrid on a WinRT project, that displays the contents of a excel file. this is the xaml i have:
<Page.Resources>
<common:CustomStyleSelector x:Key="styleselector"/>
</Page.Resources>
...
<syncfusion:SfDataGrid Grid.Row="1" x:Name="datagrid" Width="auto" Visibility="Collapsed"
Margin="10,0,10,10"
AllowResizingColumns="True"
AutoGenerateColumns="true"
AllowDraggingColumns="True"
AllowSorting="False"
ColumnSizer="Star"
RowHeight="65"
RowStyle="{StaticResource rowStyle}"
ShowRowHeader="True"
CellStyleSelector="{StaticResource styleselector}"
/>
and the CellStyleSelector uses this
public class CustomStyleSelector : StyleSelector
{
private Style cellStyle { get; set; }
private static int cellCounter;
protected override Style SelectStyleCore(object item, DependencyObject container)
{
cellCounter = cellCounter + 1;
switch (cellCounter)
{
case 3:
case 5:
case 21:
case 22:
case 23:
case 24:
case 25:
case 26:
case 27:
case 28:
case 29:
case 30:
cellStyle = Application.Current.Resources["altCustomCellStyle"] as Style;
return cellStyle;
default:
cellStyle = Application.Current.Resources["customCellStyle"] as Style;
return cellStyle;
}
}
}
and this is the styles i am using ´
<Style x:Key="customCellStyle" TargetType="syncfusion:GridCell">
<Setter Property="BorderBrush" Value="Gray" />
<Setter Property="BorderThickness" Value="1,0,0,1" />
<Setter Property="Padding" Value="0,0,0,0" />
<Setter Property="Foreground" Value="#FF2A2A2A" />
<Setter Property="FontSize" Value="13" />
<Setter Property="FontFamily" Value=" Segoe UI" />
</Style>
<Style x:Key="altCustomCellStyle" TargetType="syncfusion:GridCell">
<Setter Property="Background" Value="#49E367" />
<Setter Property="BorderBrush" Value="Gray" />
<Setter Property="BorderThickness" Value="1,0,0,1" />
<Setter Property="Padding" Value="0,0,0,0" />
<Setter Property="FontFamily" Value=" Segoe UI SemiBold" />
<Setter Property="FontWeight" Value="Bold" />
<Setter Property="Foreground" Value="#FF2A2A2A" />
<Setter Property="FontSize" Value="24" />
</Style>
everything seems to be working, the cells im searching in the switch get a #49E367 background, but for some reason my FontSize and FontFamily dont get changed.
Am i missing something?