I'm still learning to use the xamDataGrid, so maybe thats just a noob question, but i've tried the examples from this forum and none did work.
I can't set the Cellcontent alignment to right or center.
Here is what i have tried so far.
<Window.Resources> <Style TargetType="{x:Type igDP:CellValuePresenter}" > <Setter Property="HorizontalContentAlignment" Value="Right" /> </Style> </Window.Resources> <DockPanel> <igDP:XamDataGrid Name="grid"> <igDP:XamDataGrid.Resources> <Style TargetType="{x:Type igDP:CellValuePresenter}"> <Setter Property="HorizontalContentAlignment" Value="Center" /> </Style> </igDP:XamDataGrid.Resources> </igDP:XamDataGrid> </DockPanel>
it still looks this way:
My approach ist from this forum:
http://community.infragistics.com/forums/p/13669/70632.aspx
So another forum post actually provides a solution to this problem, but unless I'm setting some property incorrectly, I think the CellValuePresenterStyle should be the correct way to do this, not the solution presented here: http://blogs.infragistics.com/forums/t/51899.aspx.
Changing the Editors for ALL content types just seems wrong, wrong, wrong, but since I want to center all the numeric columns in my grid, it works for me.
Here's the solution that seems to work, instead of setting the CellValuePresenter style you set the style of the Editors:
<Grid.Resources> <Style TargetType="{x:Type igEditors:XamTextEditor}" > <Setter Property="HorizontalAlignment" Value="Center" /> <Setter Property="HorizontalContentAlignment" Value="Center" /> </Style> <Style TargetType="{x:Type igEditors:XamNumericEditor}" > <Setter Property="HorizontalAlignment" Value="Center" /> <Setter Property="HorizontalContentAlignment" Value="Center" /> </Style> <Style TargetType="{x:Type igEditors:XamDateTimeEditor}" > <Setter Property="HorizontalAlignment" Value="Center" /> <Setter Property="HorizontalContentAlignment" Value="Center" /> </Style></Grid.Resources>
Here's how my grid looks with these styles applied (for numeric editors):
I had the exact same problem and couldn't find an answer anywhere on the forums so I thought I'd post my solution. The key is creating a style with a TargetType of Control which all the editors derive from and can contains the HorizontalAlignment property. Then you can assign it to the editor style (for any editor) in FieldSettings.
<igDP:XamDataGrid.Resources>
<Style TargetType="{x:Type Control}" x:Key="EditorCenterAligned">
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
</Style>
</igDP:XamDataGrid.Resources>
...
<igDP:Field.Settings>
<igDP:FieldSettings EditorStyle="{StaticResource EditorCenterAligned}"/>
</igDP:Field.Settings>
Hi,
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.