Hi,
Our view models currently hold AxisCollection and work with IAxis. We’re hoping to switch to working with IAxisViewModel at this level.
But some feature differences will make this harder:
- IAxis.TickLabelStyle – view model only supports TickTextBrush, not the other font related properties we customise in this style.
- SImilarly MajorGridLineStyle and MinorGridLineStyle
- Is IAxisViewModel.StyleKey the equivalent of IAxis.TitleStyle? (we just need to move our style definitions to XAML instead of creating Style objects in code)
- Is IAxisViewModel.VisibleRange equivalent to IAxis.DataRange?
Can there be equivalent IAxisViewModel.TickLabelStyleKey, similarly Minor/Major grid line StyleKey?
Background
Our view models hang around to hold logical state of charts. But they also hold some AxisCollection, bound to from SciChartSurface.
We get exceptions like: InvalidOperationException Element already has a logical parent, under SciChart methods in the call stack.
E.g. when reconnecting to a PC over remote desktop, where a chart was already loaded.
This change was also suggested as a solution to our other recent issue, here:
https://www.scichart.com/questions/wpf/axiscollection-isprimaryaxis-stops-auto-updating#sabai-entity-content-13950
The “Element already has a logical parent” exception doesn’t happen when clicking between multiple charts like that latter issue. I’ve prototyped a changeover (commenting out all the bits not directly equivalent) and it seems to resolve this exception.
- You must login to post comments
Hi Michael
Any property can be set on the Axis / Series / Annotation with our MVVM API using styles. The process to do this is as follows.
Worked Example – Style a Series in MVVM
Above: The example for a series can be adapted to an axis as follows
<Style TargetType="s:NumericAxis" x:Key="AxisStyle">
<!-- Put setters for axis here -->
</Style>
<s:SciChartSurface YAxes="{s:AxisBinding YAxes}">
</s:SciChartSurface>
In your viewmodel, you tell the axis to use style key ‘AxisStyle’ as follows.
public ObservableCollection<IAxisViewModel> YAxes
{
get { return _yAxes; }
}
YAxes.Add(new NumericAxisViewModel() { StyleKey = "AxisStyle" });
Best regards,
Andrew
- Andrew Burnett-Thompson answered 5 years ago
- You must login to post comments
Please login first to submit.