SciChart WPF 2D Charts > Axis APIs > Axis Styling - Templating the Axis Title
Axis Styling - Templating the Axis Title

Templating the Axis Title

Changing Axis Title FontSize, FontFamily and Foreground

The AxisCore.AxisTitle is a string, and by default this displays a TextBlock. You can change the size of the title font using the AxisCore.TitleFontSize property. Similarly, other properties directly affect the axis title style

Changing Axis FontSize, FontFamily and Foreground
Copy Code
   <s:NumericAxis AxisTitle="Primary XAxis" FontSize="12" TitleFontSize="20"
                  FontStyle="Italic" FontFamily="Segoe UI" TitleFontWeight="Bold"   

Templating the Axis Title

It is also possible to template the axis title, for full control over the content of the title. Any WPF UserControl can go in the title style property, which can be defined as follows:

 Templating the Axis Title
Copy Code
      <!-- Define a style of targettype ContentControl -->
      <Style TargetType="ContentControl" x:Key="CustomTitle">
         <Setter Property="Template">
               <ControlTemplate TargetType="ContentControl">
                  <!-- Define any WPF UI -->
                  <Border Background="#11FFFFFF" BorderBrush="#333" BorderThickness="1" Padding="2" Margin="5">
                        <DropShadowEffect Color="Black" ShadowDepth="10" Direction="-45"/>
                     <StackPanel Orientation="Horizontal">
                        <TextBlock Text="E" FontSize="26" FontFamily="Times New Roman"/>
                        <TextBlock Text="= mc" FontSize="18" Margin="5" FontFamily="Times New Roman"/>
                        <TextBlock Text="2" FontFamily="Times New Roman"/>
   <!--  Create the chart surface  -->
   <!-- where xmlns:s="" -->

      <!--  Create XAxis  -->
         <s:NumericAxis TickTextBrush="SteelBlue" TitleStyle="{StaticResource CustomTitle}"/>

      <!--  Create YAxis  -->
         <s:NumericAxis AxisTitle="Primary YAxis" AxisAlignment="Left"/>
         <s:NumericAxis Id="SecondaryYAxisId" AxisTitle="Secondary YAxis" AxisAlignment="Right"/>


See Also