I have a custom control that contains a XamDataGrid (v10.3). AutoGenerateColumns = false and fields are dynamically and added to a FieldLayout that is then assigned as the DefaultFieldLayout. All fields bind to numeric properties of business objects. I have tried the following to center the content in my grid's cells:
From code:
foreach (Field fld in myControl.myXamDataGrid.DefaultFieldLayout.Fields) { fld.Settings.CellValuePresenterStyle = new Style(typeof(CellValuePresenter)); fld.Settings.CellValuePresenterStyle.Setters.Add(new Setter(CellValuePresenter.HorizontalContentAlignmentProperty, HorizontalAlignment.Center)); }
From XAML (UserControl.Resources):
<Style TargetType="{x:Type igDP:CellValuePresenter}"> <Setter Property="HorizontalContentAlignment" Value="Center"/> <Setter Property="HorizontalAlignment" Value="Center" /> </Style>
None of these approaches are working. Any ideas?
Thanks,
Paul
Hello Paul,
I am just checking the progress of this issue and was wondering if you managed to achieve your goal or if you need any further assistance on the matter.
Hello,
Thank you for your post. I have been looking into it and I can suggest you create a Style for the XamNumericEditor and set its HorizontalContentAlignment Property to Center, since your values are numeric. It can be defined like this:
<Style TargetType="{x:Type igEditors:XamNumericEditor}"> <Setter Property="HorizontalContentAlignment" Value="Center"/> </Style>
Please let me know if this helps you or you need further assistance on this matter.
Looking forward for your reply.