问题描述
我继承了以下样式:
<Style x:Key="MainPlanDataGridCell" TargetType="DataGridCell">
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Height" Value="30" />
<Setter Property="FrameworkElement.HorizontalAlignment" Value="Stretch" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridCell}">
<Grid Background="{TemplateBinding Background}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
</Grid>
...
</Style>
<Style x:Key="MainPlanTable" TargetType="{x:Type DataGrid}">
...
<Setter Property="CellStyle" Value="{StaticResource MainPlanDataGridCell}" />
...
</Style>
它在控件中的用法如下:
<DataGrid
Grid.Row="2"
Grid.Column="0"
...
Style="{StaticResource MainPlanTable}">
<DataGrid.Columns>
...
</DataGrid.Columns>
</DataGrid>
但是我需要使不同的单元格列具有不同的对齐方式。 有没有办法使用样式来完成此任务?如果没有,有人可以建议实现此目标的最佳方法(高级方法)吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)