SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy. We also have a tag=SciChart on where you can earn rep for your questions!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.



I’m using MVVM to dynamically add axes in the runtime with a binding to YAxes and XAxes from the SciChartSurface. like this,

<s:SciChartSurface XAxes="{Binding XAxes}" YAxes="{Binding YAxes}"/>

The problem is, since I’m creating and adding these from the ViewModel, my “AxisStyle” style (defined inside UserControl.Resources) does not automatically apply to my axes. Initially I had the style in my Resources file, which I can access from the ViewModel and manually apply it from the code.

The reason I’m changing the style’s location from Resources.xaml to the control itself is this;

 <Style x:Key="AxisStyle" TargetType="SciChart:AxisBase">
            <Setter Property="TickTextBrush" Value="{Binding GraphThemeOptions.LabelBrush}"/>
            <Setter Property="MinorTickLineStyle">
                    <Style TargetType="Line">
                        <Setter Property="Stroke" Value="{Binding GraphThemeOptions.LabelBrush"/>

I can use a proxy binding to pass the datacontext to the MinorTickLineStyle style, but only in the UserControl itself, not an external resource dictionary.

I was hoping to do something like this:

      <SciChartSurface.XAxes ItemsSource="{Binding XAxes"} Style="{StaticResource AxisStyle}"/>

But XAxes does not have any properties I can access from XAML.

What would be a good way to apply a style from XAML and still have dynamic Axes.

Thank you,

  • You must to post comments
Best Answer

Hi Kewur,

This question seems to be a duplicate of this one: Template items of an AxisCollection possible and this one MVVM Multiple Axis Example.

Can you take a look and let me know if the solution(s) above help you?

Best regards,

  • kewur
    Thank you Andrew, with a little edit to the YAxesBehaviour I got it working.
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.