I want to align my left YAaxis labels to right and fixed label width. I use Spectrogram view and want to align the left edges of those charts. (I’m using version 4.0.2)
This is my style definition:
<Style x:Key="LeftAxisLabelStyle" TargetType="s:DefaultTickLabel">
<Setter Property="HorizontalAnchorPoint" Value="Right"/>
<Setter Property="Width" Value="20"/>
</Style>
but unfortunately it doesn’t work.
- Marek Sienczak asked 8 years ago
- You must login to post comments
Hi Andrew,
Unfortunately your solution does not solve my problem. But I have found my own one. Here you are:
<Style x:Key="LeftAxisLabelStyle" TargetType="s:DefaultTickLabel">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<StackPanel>
<TextBlock Width="40" TextAlignment="Right" Text="{Binding Text}"/>
</StackPanel>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
Best regards,
Marek
- Marek Sienczak answered 8 years ago
-
Hi Marek, thank you for sharing that answer, it will surely help other people too! Best regards, Andrew
- You must login to post comments
Hi Marek,
Thank you for your question! The default axis layout doesn’t allow to right-align its internals. But, it is possible to right-align the entire axis instead.
You can achieve the desired result providing a panel with a desired Width as LeftAxesPanelTemplate and setting HorizontalAlignment on the axis:
<ItemsPanelTemplate x:Key="LeftAxesPanel">
<!-- Set the desired width on the panel -->
<Grid Width="100"/>
</ItemsPanelTemplate>
<!-- Use the panel as a container for left-aligned axes -->
<s:SciChartSurface LeftAxesPanelTemplate="{StaticResource LeftAxesPanel}">
<s:SciChartSurface.YAxis>
<s:NumericAxis Id="LeftAxis" AxisAlignment="Left" />
</s:SciChartSurface.YAxis>
</s:SciChartSurface>
Please let me know if this helps.
Best regards,
Andrew
- Andrew Burnett-Thompson answered 8 years ago
- You must login to post comments
Please login first to submit.