FontFamily未应用于DataGrid Cell

时间:2014-10-17 11:27:30

标签: c# datagrid windows-runtime winrt-xaml syncfusion

我在WinRT项目上有一个sfDataGrid,它显示excel文件的内容。 这是我的xaml:

<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}"
                           />

并且CellStyleSelector使用此

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;
        }
    }
}

这是我正在使用的样式 '

<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>
一切似乎都在工作,我在交换机中搜索的单元格得到#49E367背景,但由于某种原因,我的FontSize和FontFamily不会被更改。

我错过了什么吗?

0 个答案:

没有答案