Articles in this section
Category / Section

How to wrap the axis labels in WPF Chart (SfChart)?

1 min read

You can wrap the axis labels by customizing the LabelTemplate property of WPF Chart (SfChart) axis.

XAML

<Grid>
   <Grid.Resources>
      <DataTemplate x:Key="labelTemplate">
         <Grid Height="70" Width="40">
            <TextBlock TextWrapping="Wrap" Text="{Binding LabelContent}" FontSize="12"/>
         </Grid>
      </DataTemplate>
   </Grid.Resources>
   <chart:SfChart>
      <chart:SfChart.PrimaryAxis>
         <chart:CategoryAxis  LabelTemplate="{StaticResource labelTemplate}"/>
      </chart:SfChart.PrimaryAxis>
   </chart:SfChart>
</Grid>

The following screenshot illustrates the axis labels wrapping.

WPF Chart with Wrapped Axis Labels

 

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied