Silverlight中Datagrid控件自定义列头样式Demo

Demo如下:

<sdk:DataGrid AutoGenerateColumns="False" Height="439" Background="LightGreen" HorizontalAlignment="Left" Margin="12,70,0,0" Name="dataGrid1" VerticalAlignment="Top" Width="320" >
            <sdk:DataGrid.Columns>
                <sdk:DataGridTemplateColumn Width="100">
                    <sdk:DataGridTemplateColumn.HeaderStyle>
                        <Style TargetType="sdk:DataGridColumnHeader">
                            <Setter Property="ContentTemplate">
                                <Setter.Value>
                                    <DataTemplate>
                                        <Grid>
                                            <CheckBox Content="全选"/>
                                        </Grid>
                                    </DataTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </sdk:DataGridTemplateColumn.HeaderStyle>
                    <sdk:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox IsChecked="{Binding IsSelected,Mode=TwoWay}" Width="100" />
                        </DataTemplate>
                    </sdk:DataGridTemplateColumn.CellTemplate>
                </sdk:DataGridTemplateColumn>
                <sdk:DataGridTextColumn CanUserReorder="True" Binding="{Binding Name,UpdateSourceTrigger=PropertyChanged}" CanUserResize="True" CanUserSort="True" Header="姓名" Width="*" />
                <sdk:DataGridTextColumn CanUserReorder="True" Binding="{Binding Age,UpdateSourceTrigger=PropertyChanged}" CanUserResize="True" CanUserSort="True" Header="年龄" Width="*" />
                <sdk:DataGridTextColumn CanUserReorder="True" Binding="{Binding Addr,UpdateSourceTrigger=PropertyChanged}" CanUserResize="True" CanUserSort="True" Header="住址" Width="*" />
            </sdk:DataGrid.Columns>
</sdk:DataGrid>


©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页