积极答复者
如何设置dagagrid中的row内容底边对齐?

问题
答案
-
您好 到此一游,
抱歉,我提供的方法确实不行,原因可能是cell模板并没有利用这个属性。您可以重置模板来设置文本对齐的方式:
<DataGrid Name="grid1"> <DataGrid.CellStyle> <Style TargetType="DataGridCell"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type DataGridCell}"> <Grid Background="{TemplateBinding Background}"> <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Bottom"/> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> </DataGrid.CellStyle> </DataGrid>
Aland Li
Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.- 已标记为答案 Aland LiModerator 2010年6月13日 13:30
全部回复
-
您好 到此一游,
根据我的理解,您应该设置一下VerticalContentAlignment, 而不是VerticalAlignment。
http://msdn.microsoft.com/zh-cn/library/system.windows.controls.control.verticalcontentalignment(v=VS.100).aspxAland Li
Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread. -
您好 到此一游,
抱歉,我提供的方法确实不行,原因可能是cell模板并没有利用这个属性。您可以重置模板来设置文本对齐的方式:
<DataGrid Name="grid1"> <DataGrid.CellStyle> <Style TargetType="DataGridCell"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type DataGridCell}"> <Grid Background="{TemplateBinding Background}"> <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Bottom"/> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> </DataGrid.CellStyle> </DataGrid>
Aland Li
Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.- 已标记为答案 Aland LiModerator 2010年6月13日 13:30