Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1065
How to make text alightment based on value type
posted

Hello

When displaying an xamDataGrid field with all numeric values (gridField.DataType = numeric data type such as Integer), may I make the text right aligned?

Similarly, may I make the text left aligned if DataType is String?

Thanks

  • 69686
    Verified Answer
    posted

    Hello,

    You can achieve this by setting the HorizontalContentAlighnment property of the underlying editor. For strings, the XamDataGrid will use a XamTextEditor and for integer XamNumericEditor. Here is an example for a style of right aligned text field :

    <Style TargetType="{x:Type igEditors:XamTextEditor}">

                <Setter Property="HorizontalContentAlignment" Value="Right" />

            </Style>