Pre loader

Unable to style NumericAxis/NumericAxisViewModel AxisLabelContainerStyle or AxisLabelTemplate

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

I’m able to style the AxisLabelContainerStyle and AxisLabelTemplate for my TimeSpanAxis but it doesn’t seem to be working for my NumericAxes/NumericAxisViewModels. Attached is a photo showing the styled TimeSpanAxis (cyan) and the default NumericAxis (green).

Here are the templates:

<Style TargetType="{x:Type sci:AxisLabelControl}" x:Key="CursorAxisLabelStyle">
        <Setter Property="Background" Value="Black" />
    </Style>
    <DataTemplate DataType="{x:Type sci:AxisInfo}" x:Key="CursorNumericAxisLabelTemplate">
        <Border BorderBrush="DarkCyan" BorderThickness="1">
            <TextBlock Foreground="Cyan" Margin="2" Text="{Binding DataValue, StringFormat={}{0:0.0}}" />
        </Border>
    </DataTemplate>
    <DataTemplate DataType="{x:Type sci:AxisInfo}" x:Key="CursorTimeSpanAxisLabelTemplate">
        <Border BorderBrush="DarkCyan" BorderThickness="1">
            <TextBlock Foreground="Cyan" Margin="2" Text="{Binding DataValue, StringFormat={}{0:hh}:{0:mm}:{0:ss}}" />
        </Border>
    </DataTemplate>

Here are the styles for the axes:

<Style TargetType="{x:Type sci:NumericAxis}">
        <Setter Property="sci:CursorModifier.AxisLabelContainerStyle" Value="{StaticResource ResourceKey=CursorAxisLabelStyle}" />
        <Setter Property="sci:CursorModifier.AxisLabelTemplate" Value="{StaticResource ResourceKey=CursorNumericAxisLabelTemplate}" />
    </Style>
    <Style TargetType="{x:Type sci:TimeSpanAxis}">
        <Setter Property="sci:CursorModifier.AxisLabelContainerStyle" Value="{StaticResource ResourceKey=CursorAxisLabelStyle}" />
        <Setter Property="sci:CursorModifier.AxisLabelTemplate" Value="{StaticResource ResourceKey=CursorTimeSpanAxisLabelTemplate}" />
    </Style>

I will note that I’m binding my YAxes to an ObservableCollection because throws a binding error. But I’ve also tried using {x:Type sci:NumericAxisViewModel} which doesn’t work because it doesn’t derive from “FrameworkElement” and <x:Type sci:NumericAxisForMvvm} doesn’t style either.

I’m just not sure how to best make the NumericAxes styled.

Thanks!

Version
6.3.0.13476
Images
  • You must to post comments
0
0

Hello Greg,

Have you tried to set to your style, some “x:Key”, like this

<Style TargetType="{x:Type sci:NumericAxis}" x:Key="MyAxisStyle">
<Setter Property="sci:CursorModifier.AxisLabelContainerStyle" Value="{StaticResource ResourceKey=CursorAxisLabelStyle}" />
<Setter Property="sci:CursorModifier.AxisLabelTemplate" Value="{StaticResource ResourceKey=CursorNumericAxisLabelTemplate}" />
</Style>

And then when you’re creating\assigning your AxisViewModel just assign this key as StyleKey, like this:

var numericAxis = new NumericAxisViewModel() { StyleKey = "MyAxisStyle" };

I’ve checked this in our examples suit, and can confirm that it’s working.

  • 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