如何更改Silverlight Datagrid中数据的FontSize

时间:2012-08-03 09:58:07

标签: xaml silverlight fonts datagrid

我试图找出如何使我的Datagrid中数据的字体大小更大。

我的Datagrid XAML:

    <data:DataGrid x:Name="dgVisitData" Style="{StaticResource dgStyle}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" BorderBrush="LightSlateGray" BorderThickness="2"
                AutoGenerateColumns="False" ItemsSource="{Binding}">
        <data:DataGrid.Columns>
            <data:DataGridTextColumn Width="Auto" Header="Name" Binding="{Binding MemberName}" />
            <data:DataGridTextColumn Width="Auto" Header="Surname" Binding="{Binding MemberSurname}" />
            <data:DataGridTextColumn Width="Auto" Header="Member No" Binding="{Binding MemberNumber}" />
            <data:DataGridTextColumn Width="Auto" Header="Dependant No" Binding="{Binding MemberDependantNumber}" />
            <data:DataGridTextColumn Width="Auto" Header="Date" Binding="{Binding Date}" />
            <data:DataGridTextColumn Width="Auto" Header="Time" Binding="{Binding Time}" />
        </data:DataGrid.Columns>
    </data:DataGrid>

使用样式我可以放大标题字体大小。

我是否需要做类似的事情来更改实际数据的字体大小?

1 个答案:

答案 0 :(得分:2)

<sdk:DataGridTextColumn Binding="{Binding Name}" CanUserSort="True" SortMemberPath="Name" Header="Name">
    <sdk:DataGridTextColumn.ElementStyle>
        <Style TargetType="TextBlock">
            <Setter Property="HorizontalAlignment" Value="Left"/>
            <Setter Property="FontSize" Value="12" />
        </Style>
    </sdk:DataGridTextColumn.ElementStyle>
</sdk:DataGridTextColumn>

或者您可以为整个数据网格编写自己的数据网格样式