Hi
Based on some window’s size logic I want an ItemTemplateSelector to set the correct ItemTemplate.
But it doesn’t seem like the SciCharLegend picks up the ItemTemplateSelector, because whatever I put into the ItemTemplates it is totally ignored and only the default is rendered.
public class SciChartLegendTemplateSelector : DataTemplateSelector
{
public DataTemplate NormalItemTemplate { get; set; }
public DataTemplate SmallItemTemplate { get; set; }
public override DataTemplate SelectTemplate(object item, DependencyObject container)
{
return NormalItemTemplate;
}
}
<DataTemplate x:Key="SciChartLegendNormalItemTemplate">
<StackPanel Orientation="Horizontal">
<TextBlock Text="NORMAL"></TextBlock>
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="SciChartLegendSmallItemTemplate">
<StackPanel Orientation="Vertical">
<TextBlock Text="SMALL"></TextBlock>
</StackPanel>
</DataTemplate>
<templateSelectors:SciChartLegendTemplateSelector x:Key="SciChartLegendTemplateSelector"
NormalItemTemplate="{StaticResource SciChartLegendNormalItemTemplate}"
SmallItemTemplate="{StaticResource SciChartLegendSmallItemTemplate}"/>
<s:SciChartLegend x:Name="legendControl"
s:ThemeManager.Theme="BrightSpark"
VerticalAlignment="Bottom"
HorizontalAlignment="Stretch"
Background="White"
FontSize="10"
FontStretch="UltraCondensed"
LegendData="{Binding LegendData,
ElementName=legendModifier,
Mode=OneWay}"
ShowVisibilityCheckboxes="True"
ItemTemplateSelector="{StaticResource SciChartLegendTemplateSelector}">
- Sander Struijk asked 10 years ago
- You must login to post comments
In order for the SciChartLegend to pick up and use the ItemTemplateSelector you need to explicitly set the SciChartLegend’s ItemTemplate to null in codebehind.
- Sander Struijk answered 10 years ago
-
This is probably something that should be changed in a future version, as the default behavior should be to use the ItemTemplateSelector over the ItemTemplate if set.
- You must login to post comments
I am considering applying server-side licensing for my javerScript application.
In the document below, there is a phrase “Our server-side licensing component is written in C++.”
(https://support.scichart.com/index.php?/Knowledgebase/Article/View/17256/42/)
However, there is only asp.net sample code on the provided github.
(https://github.com/ABTSoftware/SciChart.JS.Examples/tree/master/Sandbox/demo-dotnet-server-licensing)
I wonder if there is a sample code implemented in C++ for server-side licensing.
Can you provide c++ sample code?
Also, are there any examples to run on Ubuntu?
- Guest answered 10 years ago
- last edited 10 years ago
-
Thanks I will test this out. :)
-
I'm confused How is this
using System.Windows; using System.Windows.Controls; namespace Test { public class SciChartLegendItemTemplateSelector : DataTemplateSelector {...} }
different fromusing System.Windows; namespace Test { public class SciChartLegendItemTemplateSelector : System.Windows.Controls.DataTemplateSelector {...} }
I tried using the Abt.Controls.SciChart.DataTemplateSelector but the type is not accepted, by the SciCharLegend.ItemTemplateSelector -
I'm sorry I havent made this clear, you probably need to set the ItemTemplate property to "Null" also to override the default value.
-
You are correct
public partial class ConfigurableSignalTrackView : UserControl { public ConfigurableSignalTrackView() { InitializeComponent(); legendControl.ItemTemplate = null; } }
legendControl.ItemTemplate = null; made it work, so that was the solution not the explicit namespace reference.
- You must login to post comments
Hi, I created a small sample to reproduce this bug.
MultipleLinesView.xaml
<UserControl x:Class="Test.MultipleLinesView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:SciChart="http://schemas.abtsoftware.co.uk/scichart"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:test="clr-namespace:Test"
Loaded="MultipleLinesView_OnLoaded" d:DesignHeight="300" d:DesignWidth="300" mc:Ignorable="d">
<UserControl.Resources>
<DataTemplate x:Key="XySeriesInfoItemTemplate">
<TextBlock Text="XySeriesInfo"></TextBlock>
</DataTemplate>
<DataTemplate x:Key="BandSeriesInfoItemTemplate">
<TextBlock Text="BandSeriesInfo"></TextBlock>
</DataTemplate>
<test:SciChartLegendItemTemplateSelector
x:Key="SciChartLegendItemTemplateSelector"
XySeriesInfoItemTemplate="{StaticResource XySeriesInfoItemTemplate}"
BandSeriesInfoItemTemplate="{StaticResource BandSeriesInfoItemTemplate}"/>
</UserControl.Resources>
<Grid SciChart:ThemeManager.Theme="ExpressionLight">
<Grid.RowDefinitions>
<RowDefinition Height="32"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal">
<TextBlock Margin="5" Foreground="#EEE" Text="Get Legend Data For: "/>
<ComboBox x:Name="cboGetLegendFor" SelectionChanged="CboGetLegendFor_OnSelectionChanged"/>
<CheckBox x:Name="chkbShowSeries" Content="Show Checkboxes for VisibleSeries" IsChecked="True"/>
</StackPanel>
<SciChart:SciChartSurface x:Name="sciChart" Grid.Row="1">
<!-- Declare RenderableSeries -->
<SciChart:SciChartSurface.RenderableSeries>
<SciChart:FastLineRenderableSeries SeriesColor="#279B27"/>
<SciChart:FastLineRenderableSeries SeriesColor="#FF1919"/>
<SciChart:FastLineRenderableSeries SeriesColor="#1964FF"/>
</SciChart:SciChartSurface.RenderableSeries>
<!-- Declare Axes -->
<SciChart:SciChartSurface.XAxis>
<SciChart:NumericAxis VisibleRange="0, 60"/>
</SciChart:SciChartSurface.XAxis>
<SciChart:SciChartSurface.YAxis>
<SciChart:NumericAxis VisibleRange="0, 200000"/>
</SciChart:SciChartSurface.YAxis>
<!-- Declare ChartModifiers -->
<SciChart:SciChartSurface.ChartModifier>
<SciChart:ModifierGroup>
<SciChart:LegendModifier x:Name="legendModifier"
GetLegendDataFor="AllSeries"/>
<SciChart:RolloverModifier DrawVerticalLine="True"
ShowTooltipOn="Always"
SourceMode="AllVisibleSeries"/>
</SciChart:ModifierGroup>
</SciChart:SciChartSurface.ChartModifier>
</SciChart:SciChartSurface>
<SciChart:SciChartLegend x:Name="legendControl"
Grid.Row="1"
SciChart:ThemeManager.Theme="{Binding Path=(SciChart:ThemeManager.Theme),
RelativeSource={RelativeSource AncestorType=Grid}}"
Margin="23,23"
LegendData="{Binding LegendData,
ElementName=legendModifier,
Mode=OneWay}"
ShowVisibilityCheckboxes="{Binding IsChecked,
ElementName=chkbShowSeries}"
ItemTemplateSelector="{StaticResource SciChartLegendItemTemplateSelector}">
</SciChart:SciChartLegend>
</Grid>
</UserControl>
MultipleLinesView.xaml.cs
public partial class MultipleLinesView : UserControl
{
public MultipleLinesView()
{
InitializeComponent();
cboGetLegendFor.Items.Add(SourceMode.AllSeries);
cboGetLegendFor.Items.Add(SourceMode.AllVisibleSeries);
cboGetLegendFor.SelectedItem = SourceMode.AllSeries;
}
private void MultipleLinesView_OnLoaded(object sender, RoutedEventArgs e)
{
// Add some data series of type X=double, Y=double
var dataSeries0 = new XyDataSeries<int, int> { SeriesName = "Curve A" };
var dataSeries1 = new XyDataSeries<int, int> { SeriesName = "Curve B" };
var dataSeries2 = new XyDataSeries<int, int> { SeriesName = "Curve C" };
var data1 = DataManager.Instance.GetStraightLine(1000, 1.0, 60);
var data2 = DataManager.Instance.GetStraightLine(2000, 1.0, 60);
var data3 = DataManager.Instance.GetStraightLine(3000, 1.0, 60);
// Append data to series.
dataSeries0.Append(data1.XData, data1.YData);
dataSeries1.Append(data2.XData, data2.YData);
dataSeries2.Append(data3.XData, data3.YData);
sciChart.RenderableSeries[0].DataSeries = dataSeries0;
sciChart.RenderableSeries[1].DataSeries = dataSeries1;
sciChart.RenderableSeries[2].DataSeries = dataSeries2;
// Zoom to extents of the data
sciChart.ZoomExtents();
}
private void CboGetLegendFor_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (legendModifier != null)
{
legendModifier.GetLegendDataFor = (SourceMode)cboGetLegendFor.SelectedItem;
}
}
}
Here you can see a screenshot of the result
Clearly you can see here that the template returned by the ItemTemplateSelector is not used.
- Sander Struijk answered 10 years ago
- last edited 10 years ago
-
Hi Sander, thank you for your feedback and sample to reproduce - we have logged a bug on our side and someone will investigate it soon.
-
Thanks Andrew, great help! :)
- You must login to post comments
Please login first to submit.