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
85
Problems with HorizontalContentAlignment
posted

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

 

 

Parents
  • 50
    posted

    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):

     

Reply Children