标签:style c class blog code java
1在全局App.xaml文件中声明
1 <!--表格模版 --> 2 <!--单元格 文本居中 跨行--> 3 <Style TargetType ="TextBlock" x: Key="dgCell"> 4 <Setter Property ="TextAlignment" Value="Center"></ Setter> 5 <Setter Property="TextWrapping" Value ="Wrap"></Setter> 6 </Style> 7 <!--标题 居中跨行--> 8 <Style TargetType ="DataGridColumnHeader" x: Key="dgHeader"> 9 <Setter Property ="HorizontalContentAlignment" Value="Center"></Setter > 10 <Setter Property ="ContentTemplate"> 11 <Setter.Value> 12 <DataTemplate> 13 <TextBlock Text ="{Binding}" TextWrapping="Wrap" TextAlignment ="Center" HorizontalAlignment="Center"/> 14 </DataTemplate> 15 </Setter.Value> 16 </Setter> 17 </Style>
1 <DataGridTextColumn ElementStyle ="{StaticResource dgCell }" HeaderStyle ="{ StaticResource dgHeader }"/>
DataGrid表格的表头换行和内容居中,布布扣,bubuko.com
标签:style c class blog code java
原文地址:http://www.cnblogs.com/JoanLin-workNotes/p/3751884.html