Pre loader

How to programmatically add Scrollbars to MVVM instantiated axes?

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


How to programmatically add Scrollbars to MVVM instantiated axes?

I added DateTimeAxisViewModel and NumericAxisViewModel to my code. That works from so far. A way to add scrollbars i couldnt find a some tries.

Are there some ways to get this done? Maybe change the templates of the axes or the chart?

Best regards

  • You must to post comments

SciChart SDK – SC-WPF-SDK-PRO Trial

Thank you for the quick response. But i am afraid i am still stuck.

A very exact replication of the example integrated in my code, throws “Unable to cast object of type ‘System.String’ to type ‘System.Windows.Style’.” exception. It isnt catched and crashes to the unhandled exception event handler.

For the custom numeric it is like that and if i step past the exception the style is applied. For DateTimeAxis is isnt working like that at all. Instead directly followed with an: “System.InvalidOperationException”, like “The application is already execution the dispatcher” .

That first unhandeld exception can’t be good anyway.

Maybe because i declare the SciChartSurface in a DataTemplate?
Maybe it is an interaction with the Xceed WPF Tools Avalon Dock?

  • Andrew Burnett-Thompson
    Hi Alex, have you ever tried to debug code without seeing it? It’s hard :D Show us what’s going wrong and what you have tried and maybe we can try to help
  • You must to post comments

I am trying to add Scrollbars to MVVM instantiated axes now and found this Q&A. Is there an updated way of doing this now? I found that by just setting a few properties to the axis will create the exception Alex saw in the Sand Box project. For example, just adding AxisAlignment to the axis creation will break the scrollbar example:

YAxes.Add(new NumericAxisViewModelWithScrollbar() { HasScrollbar = true, StyleKey = “ScrollbarAxisStyle”, AxisAlignment = AxisAlignment.Left});

Any suggestions?



  • You must to post comments

That’s a good question,

We don’t have a mechanism to do it built in to the API, but you could quite easily write a custom style to enable scrollbars on the axis in MVVM.

I have created an example for you and uploaded to our Sandbox on github.

The sample is found at Sandbox/UsefulExamples/Examples/ScrollbarMvvmAxis/ScrollbarMvvmAxis.xaml

Best regards,

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.