How to set Axis TitleTemplate from code behind

0 Answers 22 Views
Top achievements
Rank 1
Cosmin asked on 04 Feb 2022, 04:33 PM


I'm using SeriesDescriptorSelector + SeriesDesciptor i order to create series.

Based on the viewmodel info. the axis series are also created on when the series are  created, on CreateInstanceCore method.

Evething works fin except the axis TitleTemplate.


protected override ChartSeries CreateInstanceCore(object context)
            IChartSerieViewModel viewModel = context as IChartSerieViewModel;
            var result = base.CreateInstanceCore(context);
            viewModel.ChartSeries = result;

            var scl = (viewModel.ChartSeries as ScatterLineSeries);

            scl.HorizontalAxis = new LinearAxis();
            scl.HorizontalAxis.DataContext = viewModel.SerieSettings.HorizontalAxis;

            scl.VerticalAxis = new LinearAxis();
            scl.VerticalAxis.DataContext = viewModel.SerieSettings.VerticalAxis;

            return result;



here is the Bind method


 public void Bind(CartesianAxis axis)
            if (axis == null)

            SetLabelIntervalAxisBinding(axis, nameof(LabelInterval), this);
            SetLabelFormatAxisBinding(axis, nameof(LabelFormat), this);
            SetTitleAxisBinding(axis, nameof(Title), this);
            SetVisbilityBinding(axis, nameof(IsVisible), this);
            if (axis is LinearAxis)
                SetMaxAxisBinding(axis as LinearAxis, nameof(Maximum), this);
                SetMinAxisBinding(axis as LinearAxis, nameof(Minimum), this);
            if (axis is CategoricalAxis)
                (axis as CategoricalAxis).PlotMode = Telerik.Charting.AxisPlotMode.OnTicksPadded;
                (axis as CategoricalAxis).MajorTickInterval = 1;
            SetColorAxisBinding(axis, nameof(AxisColor), this);

            var rers = axis.FindResource("AxisTemplateTitle");

            axis.TitleTemplate = Application.Current.Resources["AxisTemplateTitle"] as DataTemplate;


like I said, the binding works fine,, but even if the TitleTemplate is set, the chart won't display the title.


Any info is highly appreciated.


Thank you

No answers yet. Maybe you can help?

Asked by
Top achievements
Rank 1
Share this question