Pre loader

Axis grid line color when binding to AxisCollection

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

0
0

There are multiple Y axes in my chart. I am displaying grid lines only for the primary axis and I would like to change its color. Please let me know how it might be possible.
I have tried style and it works for X axis (single axes) but doesn’t for Y axes (multiple)

    <Style x:Key="MajorGridLineStyle" TargetType="Line">
        <Setter Property="Stroke" Value="Red"/>
    </Style>


        <s:SciChartSurface.XAxis>
            <s:NumericAxis AxisTitle="{Binding XAxisTitle}" DrawMajorBands="False" DrawMinorGridLines="False" DrawMinorTicks="False"
                           MajorGridLineStyle="{StaticResource MajorGridLineStyle}"/>
        </s:SciChartSurface.XAxis>

I have also tried majorgridlinebrush in my viewmodel but it doesn’t work. Some default color is show for the gridlines

        YAxes.Add(new NumericAxisViewModel
        {
            DrawMajorBands = false,
            DrawMinorGridLines = false,
            DrawMinorTicks = false,
            MajorGridLinesBrush = new SolidColorBrush(Colors.Red)
        });
Version
6.5
  • You must to post comments
0
0

Hi Kapil

I modified this sample I shared with you last week about Axis MVVM styling,

Added this one line to MainViewModel

    public MainViewModel()
    {
        YAxisViewModels.Add(new NumericAxisViewModel()
        {
            // Apply a style key here to apply a named style to this axis
            StyleKey = "YAxisStyle",
            AxisTitle = "Y Axis",
            MajorGridLinesBrush = Brushes.Purple // this line
        });

I was able to reproduce the problem you saw, where MajorGridLinesBrush wasn’t applied.

I suggest as a workaround now, using the AxisMVVM styling technique I previously described here.

I have also reported a bug, SC-6704 AxisViewModel.MajorGridlinesBrush seems to be ignored

Best regards
Andrew

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies