mirror of
https://gitee.com/handyorg/HandyControl.git
synced 2024-11-30 19:08:08 +08:00
ggcy-冲突合并
This commit is contained in:
commit
b8e49909eb
@ -46,13 +46,16 @@ title: DataGrid 数据表格
|
|||||||
|
|
||||||
**常见问题:**
|
**常见问题:**
|
||||||
{% note warning no-icon%}
|
{% note warning no-icon%}
|
||||||
对于文本显示列`DataGridTextColumn`需要设定文本内容`水平居中`或者`水平居右`,而不是HandyControl中设定的样式默认显示为`居左`时,需要继承`DataGridCellStyle`重写`HorizontalContentAlignment` 属性为`Center` 或`Right` 需要注意的是,此方式仅仅使用与引入了HandControl资源样式的项目,普通原生DataGrid使用该方式无效。
|
对于文本显示列`DataGridTextColumn`需要设定文本内容`水平居中`或者`水平居右`,而不是HandyControl中设定的样式默认显示为`居左`时,需要继承`DataGridCellStyle`重写`HorizontalContentAlignment` 属性为`Center` 或`Right` 需要注意的是,此方式仅仅适用于引入了HandControl资源样式的项目,普通原生DataGrid使用该方式无效。
|
||||||
|
|
||||||
|
{% endnote %}
|
||||||
|
|
||||||
用例如下:
|
用例如下:
|
||||||
|
|
||||||
{% code %}
|
{% code %}
|
||||||
|
|
||||||
样式:
|
样式:
|
||||||
|
|
||||||
<Style x:Key="DataGridTextCenterColumnStyle" TargetType="DataGridCell" BasedOn="{StaticResource DataGridCellStyle}">
|
<Style x:Key="DataGridTextCenterColumnStyle" TargetType="DataGridCell" BasedOn="{StaticResource DataGridCellStyle}">
|
||||||
<Setter Property="HorizontalContentAlignment" Value="Center"/>
|
<Setter Property="HorizontalContentAlignment" Value="Center"/>
|
||||||
</Style>
|
</Style>
|
||||||
@ -61,15 +64,17 @@ xaml中的使用:
|
|||||||
|
|
||||||
<DataGrid ItemsSource="{Binding Datas}" AutoGenerateColumns="False">
|
<DataGrid ItemsSource="{Binding Datas}" AutoGenerateColumns="False">
|
||||||
<DataGrid.Columns>
|
<DataGrid.Columns>
|
||||||
<DataGridTextColumn Header="居左" Binding="{Binding Name}" Width="*"></DataGridTextColumn>
|
<DataGridTextColumn Header="居左" Binding="{Binding Name}" Width="*">
|
||||||
<DataGridTextColumn Header="居中" CellStyle="{StaticResource DataGridTextCenterColumnStyle}" Width="*" Binding="{Binding Name}"></DataGridTextColumn>
|
|
||||||
</DataGrid.Columns>
|
</DataGridTextColumn>
|
||||||
</DataGrid>
|
<DataGridTextColumn Header="居中" CellStyle="{StaticResource DataGridTextCenterColumnStyle}" Width="*" Binding="{Binding Name}">
|
||||||
|
|
||||||
|
</DataGridTextColumn>
|
||||||
|
</DataGrid.Columns>
|
||||||
|
</DataGrid>
|
||||||
|
|
||||||
{% endcode %}
|
{% endcode %}
|
||||||
|
|
||||||
效果如下:
|
效果如下:
|
||||||
|
|
||||||
![DataGridWarning01](../images/DataGrid-Warning01.png)
|
![DataGridWarning01](../images/DataGrid-Warning01.png)
|
||||||
|
|
||||||
{% endnote %}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user