0

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?

Thought
  • 5,326
  • 7
  • 33
  • 69
  • Syncfusion does not provide any support here, you'll probably have better odds getting an answer by using the vendor's support channels. – Hans Passant Oct 17 '14 at 11:54
  • I also asked in their foruns, but i thought someone here might give me some hints :) – Thought Oct 17 '14 at 13:10
  • 1
    I'd suggest testing with a visual tree debugger like XAML Spy or WinRT XAML Toolkit to see where the font is coming from. Perhaps using a `DataTemplateSelector` + `StyleSelector` would work. – Filip Skakun Oct 17 '14 at 20:32
  • @Ric follow up on the below forum, http://www.syncfusion.com/forums/117407/how-to-change-style-of-specific-row-in-a-sfdatagrid-control – Sivakumar Nov 10 '14 at 08:26

0 Answers0