Is there a way to "style" flexgrid columns?

Posted by: egor.kachiguine on 4 January 2019, 11:06 am EST

    • Post Options:
    • Link

    Posted 4 January 2019, 11:06 am EST

    I know they’re not framework objects, but is there a way to set local defaults for columns (things like HeaderHorizontalAlignment, HeaderTextWrapping, etc)?

  • Posted 6 January 2019, 4:04 pm EST

    Hi,

    FlexGrid Header cells are organized into a GridPanel(a Framework Element), which can be accessed using FlexGrid.ColumnHeaders property. Also, Header cells are TextBlock elements so, you can specify the default Style for these TextBlocks (Header Cells) inside the Resources of ColumnHeaders GridPanel as follows:

    
    flexGrid.ColumnHeaders.Resources = innerGrid.Resources;
    
    

    Where innerGrid is as follows:

    
    <Grid x:Name="innerGrid" Visibility="Collapsed">
     <Grid.Resources>
      <Style TargetType="{x:Type TextBlock}">
       <Setter Property="HorizontalAlignment" Value="Center"/>
       <Setter Property="TextWrapping" Value="Wrap"/>
      </Style>
     </Grid.Resources>
    </Grid>
    
    

    Please refer the attached sample (prj_DefaultColumnStyle) for the same.

    Thanks and Regards,

    Basant

    prj_DefaultColumnStyle.zip

  • Posted 7 January 2019, 6:47 am EST

    Ok thank you.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels