|
<syncfusion:SfChart.Resources>
<ItemsPanelTemplate x:Key="itemPanelTemplate">
<WrapPanel Width="150"/>
</ItemsPanelTemplate>
</syncfusion:SfChart.Resources>
<syncfusion:SfChart.Legend>
<syncfusion:ChartLegendCollection>
<syncfusion:ChartLegend ItemsPanel="{StaticResource itemPanelTemplate}"/>
</syncfusion:ChartLegendCollection>
</syncfusion:SfChart.Legend> |
|
<syncfusion:SfChart.Resources>
<ItemsPanelTemplate x:Key="itemPanelTemplate">
<local:CustomGrid>
<local:CustomGrid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</local:CustomGrid.RowDefinitions>
<local:CustomGrid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</local:CustomGrid.ColumnDefinitions>
</local:CustomGrid>
</ItemsPanelTemplate>
</syncfusion:SfChart.Resources> |
|
public class CustomGrid : Grid
{
protected override void OnVisualChildrenChanged(DependencyObject visualAdded, DependencyObject visualRemoved)
{
base.OnVisualChildrenChanged(visualAdded, visualRemoved);
if (visualAdded != null)
{
var content = visualAdded as ContentPresenter;
var label = (content.DataContext as LegendItem).Label;
if (label == "A-Column")
{
Grid.SetRow(content, 0);
}
else if (label == "M-Scatter")
{
Grid.SetRow(content, 1);
}
else if (label == "N-TopLine")
{
Grid.SetRow(content, 1);
Grid.SetColumn(content, 1);
}
else
{
Grid.SetRow(content, 2);
Grid.SetColumn(content, 0);
}
}
}
}
|