Hello and happy new year from Italy :)
I defined a common style for all the grid controls (XamDataGrid) that are used in my application.I would like to add this style a new "feature": all columns headers must be centered.
This is actually accomplished by setting this property on each grid's definition:
<igDP:XamDataGrid .. > <igDP:XamDataGrid.FieldSettings> <igDP:FieldSettings LabelTextAlignment="Center" /> </igDP:XamDataGrid.FieldSettings> </igDP:XamDataGrid>
What I would like to do now is assigning this property directly from the common style, in this way:
<Style TargetType="{x:Type igDP:XamDataGrid}"> <Setter Property="FieldSettings"> <Setter.Value> <igDP:FieldSettings LabelTextAlignment="Center" /> </Setter.Value> </Setter> </Style>
Unfortunately this doesn't work, as Alex pointed out some years ago in this thread:http://es.infragistics.com/community/forums/t/33158.aspx
Is there a better solution or a workaround, to avoid setting the property individually on each grid, throughout the application?Thanks, bye. Maria
No, this isn't the right solution for two reasons:
1- separate styles: i don't get any benefit from having a separate style for each grid. The advantage would be having a single style, with common settings.
2- label presenter: these settings will display the caption centered, but "buttonized" only under the centered text. With our grid settings, this isn't the right way to obtain a centered look.
Thanks anyway, bye!
HI,
You could create separate styles for each type of XamDataGrid then set the XamDataGrid Style property to that style.
If you just need to center align the label, you could create style targeing the LabelPresenter
<Style x:Key="xyz" TargetType="{x:Type igDP:LabelPresenter}">
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
</Style>
Sincerely, Matt
Developer Support Engineer
Hi Matt,thank you.
All the grids *do* have their own FieldSettings defined, since they need to set other properties, in addition to the one defined in style.Is there a possibility to "extend" the base settings that comes from the style?
Thank you, bye.
Your style will work, place it in the App.xaml. Make sure none of the XamDataGrid's have FieldSetting defined in xaml.
Sincerely,
Matt