Home Forums WPF controls Xceed DataGrid for WPF Center text in ColumnManagerCell

Viewing 15 posts - 1 through 15 (of 25 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #24072 |

    Hi there,

    how can i center the text displayed in the ColumnManagerCell?

    Thanks for any help, best regards

    b.greber

    Imported from legacy forums. Posted by Benno (had 14381 views)

    Xceed Support
    Member
    Post count: 5658

    Set the VerticalContentAlignment and HorizontalContentAlignment properties of the column-manager cell:

    <code>
    <DataTemplate>
    <xcdg:ColumnManagerRow>
    <xcdg:ColumnManagerCell FieldName=”ShipCountry” VerticalContentAlignment=”Center”
    HorizontalContentAlignment=”Center”/>
    </xcdg:ColumnManagerRow>
    </DataTemplate>
    </code>

    Imported from legacy forums. Posted by Jenny [Xceed] (had 270 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi jenny,

    thank you for your fast reply!

    Where do i implement this into my code? Can i define a global style for all columns using your method?

    best regards, b.greber

    Imported from legacy forums. Posted by Benno (had 552 views)

    Xceed Support
    Member
    Post count: 5658

    You can either do it as a style in the resources or directly in the definitition of the ColumnManagerRow in the FixedHeaders section, as such:

    <code>
    <xcdg:DataGridControl.View>
    <xcdg:TableView>
    <xcdg:TableView.FixedHeaders>
    <xcdg:ClearHeadersFooters/>
    <DataTemplate>
    <xcdg:ColumnManagerRow>
    <xcdg:ColumnManagerCell FieldName=”ShipCountry” VerticalContentAlignment=”Center”
    HorizontalContentAlignment=”Center”/>
    </xcdg:ColumnManagerRow>
    </DataTemplate>
    </xcdg:TableView.FixedHeaders>
    </xcdg:TableView>
    </xcdg:DataGridControl.View>
    </code>

    Imported from legacy forums. Posted by Jenny [Xceed] (had 358 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi,

    Im sorry for the inconvenience, but i just tried the following:

    <Style TargetType=”{x:Type xcdg:ColumnManagerCell}”>
    <Setter Property=”HorizontalContentAlignment” Value=”Center”/>
    <Setter Property=”VerticalContentAlignment” Value=”Center”/>
    </Style>

    but it doesnt seem to have any effect on my column-headers

    I also tried it the way you mentioned but then i get:
    “Property ‘Cells’ was not found or is not serializable for type “ColumnManagerRow”.

    Thanks in advance, best regards

    b.greber

    Imported from legacy forums. Posted by Benno (had 604 views)

    Xceed Support
    Member
    Post count: 5658

    What theme are you using? In some cases, the content alignment might be defined by the theme. Also, are you certain that the style is defined in a scope where it can be used by the column-manager cells?

    Imported from legacy forums. Posted by Jenny [Xceed] (had 534 views)

    User (Old forums)
    Member
    Post count: 23064

    Im using the default-theme, and I defined the Style in the DataGridControl.Resources

    Imported from legacy forums. Posted by Benno (had 810 views)

    Xceed Support
    Member
    Post count: 5658

    What is the theme of the OS then ? ( we sync with the OS for the Grid Theme, if not explicitly specified)

    Imported from legacy forums. Posted by Marcus [Xceed] (had 604 views)

    User (Old forums)
    Member
    Post count: 23064

    If you mean the XP-theme, its the default “Blue (Default)” theme

    Imported from legacy forums. Posted by Benno (had 428 views)

    Xceed Support
    Member
    Post count: 5658

    It seems to be a deficiency of the ColumnManagerRow’s ControlTemplate…

    I have noted the issue…

    In the mean time, you could use your own ControlTemplate to correct the deficiency…

    Imported from legacy forums. Posted by Marcus [Xceed] (had 480 views)

    User (Old forums)
    Member
    Post count: 23064

    ive tried to find a workaround for this .. but .. what do i have to use as binding for the text property if i use a textblock like that:

    <Style TargetType=”{x:Type xcdg:ColumnManagerCell}”>
    <Setter Property=”Template”>
    <Setter.Value>
    <ControlTemplate>

    <TextBlock Text=”{Binding ????}” HorizontalContentAlignment=”Center”/>

    </ControlTemplate>
    </Setter.Value>
    </Setter>
    </Style>

    Am i completely wrong with my code?

    Thanks,regards b.greber

    Imported from legacy forums. Posted by Benno (had 525 views)

    User (Old forums)
    Member
    Post count: 23064

    and by the way: how can i get the glyph for sorting and the borders on the left and right of the cell back?

    Imported from legacy forums. Posted by Benno (had 667 views)

    Xceed Support
    Member
    Post count: 5658

    The expression would be:

    “{xcdg:CellContentBinding}”

    The glyph is really something you need to do by yourself in the template, its not something that need to be “plugged” like a named part or something…

    I suggest taking a look at the default ColumnManagerRow ControlTemplate as a reference for doing this. It is located in the “theme\Common\TableView.GridElementTemplates.xaml” file (lookup the resource named “tableViewColumnManagerCellTemplate” ).

    Note: Watch out not to repeat the same deficiency as the one you found in the actual template !! (namely, placing the Cell’s ContentPresenter and the Glyph’s ContentPresenter in a Horizontal StackPanel). You might want to stack them vertically, to use a dock panel or use a grid to layout them “independently”.

    Imported from legacy forums. Posted by Marcus [Xceed] (had 809 views)

    User (Old forums)
    Member
    Post count: 23064

    ok thanks .. ill try to work something out with your infos..

    will this ‘”issue” be fixed in upcoming versions?
    im quiet sure im not the only one who wants to center the content of the columnmanagercell 🙂

    thanks for your help

    Imported from legacy forums. Posted by Benno (had 376 views)

    Xceed Support
    Member
    Post count: 5658

    It will be fixed in an upcoming version… which one and/or the timeframe for that release is to be determined at the moment.

    Imported from legacy forums. Posted by Marcus [Xceed] (had 539 views)

Viewing 15 posts - 1 through 15 (of 25 total)
  • You must be logged in to reply to this topic.