zoukankan      html  css  js  c++  java
  • silverlight 4中datagrid列标题和列内容居中问题

    在ASP.NET中gridview控件,我们可以直接通过设置属性就可以设置列居中了,但是今天发现在silverlight 4中不能那样搞了,设置居中还要额外的加一个

    命名空间:xmlns:Primitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Data"

    再通过定义统一资源样式

    <Style x:Key="DataGridHeaderStyle" TargetType="Primitives:DataGridColumnHeader">
                    <Setter Property="HorizontalContentAlignment" Value="Center"></Setter>
                </Style>
                <Style x:Key="DataGridCellStyle" TargetType="data:DataGridCell">
                    <Setter Property="HorizontalContentAlignment" Value="Center" ></Setter>
                </Style>

    然后在要居中的列引用这个样式如

     CellStyle="{StaticResource DataGridCellStyle}"

     HeaderStyle="{StaticResource DataGridHeaderStyle}"这个是列头

  • 相关阅读:
    treeview 的动态的绑定
    数据库组件
    webconfig,form验证存角色
    treeView
    web.config 的读写与配置
    .net 开发精华
    asp.net
    在ASP.NET中实现AJAX
    验证js
    用js将form表单同时提交到两个不同页面的方法
  • 原文地址:https://www.cnblogs.com/guoyuanwei/p/1924163.html
Copyright © 2011-2022 走看看