简体   繁体   中英

Header style datagrid silverlight

I am using silverlight and cant edit the header style of the data grid.

<sdk:DataGridTemplateColumn.HeaderStyle>
    <Style>
        <Setter Property="FontSize" Value="14" />
        <Setter Property="Background" Value="Pink"/>
    </Style>
</sdk:DataGridTemplateColumn.HeaderStyle>

It's written that member FontSize and Background are not accessible.

What should i do?

Try changing it to:

<sdk:DataGridTemplateColumn.HeaderStyle>
    <Style xmlns:primitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Data" 
           TargetType="primitives:DataGridColumnHeader">
        <Setter Property="FontSize" Value="14" />
        <Setter Property="Background" Value="Pink"/>
    </Style>
</sdk:DataGridTemplateColumn.HeaderStyle>

It should allow you set the properties with that namespace and target type added. You could also just add the namespace to the user control, instead of putting it in the style.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM