Pre loader

Tag: ItemTemplateSelector

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 votes
12k views

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}">
Showing 1 result

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies