how can i apply styling for legend in legend modifier? i want to apply the following style
<Style x:Key="LegendStyle" TargetType="s:LegendModifier">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<s:SciChartLegend x:Name="legendControl" Margin="2,2" Orientation="Horizontal" Background="Transparent" BorderThickness="0" ScrollViewer.VerticalScrollBarVisibility="Auto"
Visibility="{Binding IsLegendVisible,Converter={StaticResource BoolToVisibilityConverter}}"
LegendData="{Binding LegendData, ElementName=legendModifier,Mode=OneWay}">
<s:SciChartLegend.Resources>
<SciChart:ColorToBrushConverter x:Key="ColorToBrushConverter"/>
</s:SciChartLegend.Resources>
<s:SciChartLegend.ItemTemplate>
<DataTemplate DataType="SciChart:XyzSeriesInfo">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Rectangle Grid.Column="0"
VerticalAlignment="Center"
Stretch="Fill"
Width="10"
StrokeThickness="10"
Stroke="{Binding SeriesColor,
Converter={StaticResource ColorToBrushConverter}}" />
<TextBlock Grid.Column="1" Foreground="Black"
Margin="2,0,15,0"
HorizontalAlignment="Center"
Text="{Binding SeriesName}" FontWeight="Normal"/>
</Grid>
</DataTemplate>
</s:SciChartLegend.ItemTemplate>
</s:SciChartLegend>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
- Raghupathy asked 10 years ago
- last edited 10 years ago
- You must login to post comments
Hi Raghupathy,
Have you seen our Legend API Overview article? It shows you the legend API, including templating the legend items.
We also have an advanced tutorial on legend item templating to introduce custom fields into the legend. Perhaps this helps?
If not, please explain clearly what you need and we will do our best to help.
Best regards,
Andrew
- Andrew Burnett-Thompson answered 10 years ago
-
I want to display the legends outside of the chart surface i can't able to use ""
-
I want to show the legends outside of the chart surface i can do that for GetLegendDataFor="AllSeries" but i can't do that for GetLegendDataFor="AllVisibleSeries" i got a error message saying that 'Set property 'Abt.Controls.SciChart.ChartModifiers.LegendModifier.GetLegendDataFor' threw an exception.' Line number '67' and line position '39'. I create the chart when my application launch after when the user select the y axis value then only polt the graph.I think this is the problem.also how can i change the legend color it always white??
-
Hi Raghupathy, I believe there was a bug reported with GetLegendDataFor ... see https://www.scichart.com/questions/question/how-programatically-add-legend-to-chart. It was fixed in build 5199. Can you double-check the latest nightly build and let us know if it resolves the problem? If not, please let me know. One of the team will investigate. For your other question - legend color white, why not create a new question, we will answer it asap. Best regards, Andrew
- You must login to post comments
Please login first to submit.