SciChartLegendコントロールは、 LegendModifier.LegendDataプロパティを介して SeriesInfo の ObservableCollection にバインドすることによってデータを表示する単純なItemsControlです。
英語で言うと、ItemsControl で階層グループを表示する方法がわかれば、SciChart Legend コントロールでも同じことができるということです。
行う必要があるのは、ItemsControl から継承する独自のクラスを作成して LegendModifier.LegendData にバインドし、必要に応じて項目をグループ化することです。または、添付されたビヘイビアーまたはコンバーターを使用してアイテムをグループ化します。
次に、 LegendModifier Documentationのテクニックを使用して、独自のクラスまたは ItemsControl (SciChartLegend の代わりに) を使用できます。
別の方法 – LegendModifier.LegendData を SciChartLegend にバインドする
または、LegendModifier.LegendData を SciChartLegend にバインドして、アプリケーションの任意の場所に配置することもできます。LegendModifier.LegendData を ItemsControl.ItemsSource にバインドし、必要に応じてテンプレート化することもできます。
<!-- Somewhere else in your application, you can declare n ItemsControl -->
<!-- and bind to LegendModifier.LegendData -->
<ItemsControl
Margin="23,23"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollBarVisibility="Auto"
<!-- Here you may need a converter or attached behaviour to group the SeriesInfo as you wish -->
ItemsSource="{Binding LegendData.SeriesInfo, ElementName=legendModifier, Mode=OneWay}">
<ItemsControl.ItemTemplate>
<!-- Here you may need a Hierachical Data Template to display hierachical data -->
<DataTemplate x:Key="SciChartLegendItemTemplate" DataType="chartData:SeriesInfo">
<StackPanel Orientation="Horizontal">
<CheckBox Margin="5,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
IsChecked="{Binding RenderableSeries.IsVisible, Mode=TwoWay}"
Visibility="Visible" />
<r:PointMarker Width="40"
Height="10"
Margin="5,0,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
DataContext="{Binding RenderableSeries}"
DeferredContent="{Binding LegendMarkerTemplate}"
Visibility="{Binding ShowSeriesMarkers, RelativeSource={RelativeSource AncestorType=visuals:SciChartLegend}, Converter={StaticResource BooleanToVisibilityConverter}}" />
<TextBlock Margin="5,0,5,0"
HorizontalAlignment="Left"
Text="{Binding SeriesName}" />
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
このようなものは完全な解決策ではありませんが、SciChart Legend API を使用して ItemsControl とテンプレートの凡例項目を置き換える方法を示しています。そこから、アイテムをグループ化し、データを階層的に表示できるようになることを願っています。