Posted 17 August 2023, 7:03 am EST
Hello,
I am using the component one flexgrid .net 6.0.
can you please let me know how to wrap the flex grid column headers?
Forums Home / ComponentOne / WPF Edition
Posted by: rambabu on 17 August 2023, 7:03 am EST
Posted 17 August 2023, 7:03 am EST
Hello,
I am using the component one flexgrid .net 6.0.
can you please let me know how to wrap the flex grid column headers?
Posted 18 August 2023, 9:59 pm EST
To wrap the column headers in ComponentOne FlexGrid for .NET 6.0, you’ll need to apply a custom style to the headers. Here’s how you can achieve that:
<Window.Resources>
<Style x:Key="WrappedHeaderStyle" TargetType="{x:Type c1:C1Header}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type c1:C1Header}">
<TextBlock Text="{Binding Column.Header}" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
XAML:
<c1:C1FlexGrid x:Name="flexGrid">
<c1:C1FlexGrid.Columns>
<c1:Column Header="Long Header Text" HeaderStyle="{StaticResource WrappedHeaderStyle}" />
<!-- Other columns -->
</c1:C1FlexGrid.Columns>
</c1:C1FlexGrid>
Code-behind:
var wrappedHeaderStyle = FindResource("WrappedHeaderStyle") as Style;
column.HeaderStyle = wrappedHeaderStyle;
By setting the TextWrapping property to Wrap in the TextBlock within the custom style, you’ll ensure that the column headers wrap to multiple lines if their text is too long to fit in a single line.
Feel free to adjust the styling and appearance according to your design requirements. If you have more questions or need further help, just let me know!
Posted 19 August 2023, 10:28 pm EST
Hi Rambabu,
The solution provided by John might be feasible for FlexGrid .NET framework API. However, we are in discussions with the developers to achieve the desired behavior using the .NET 6 API. [Internal Tracking ID: C1XAML-34872]
We will update you soon on this.
Thanks & Regards,
Aastha
Posted 20 August 2023, 2:55 pm EST
Thank you for the update. We look forward to hearing from you soon.
Posted 21 August 2023, 2:30 pm EST
Hi Rambabu,
As per the information provided by the developers, current column headers do not have a support for wrapping the content. The developers have acknowledged this as a limitation.
Please let us know if you need any further help regarding this.
Thanks & Regards,
Aastha