<chart:SfChart >
<ContextMenu >
<MenuItem Header="Legend">
<MenuItem Header="DockPosition">
<MenuItem Name="top" Header="Top" Click="top_Click"/>
<MenuItem Name="bottom" Header="Bottom" Click="top_Click"/>
<MenuItem Name="left" Header="Left" Click="top_Click"/>
<MenuItem Name="right" Header="Right" Click="top_Click"/>
</MenuItem>
<MenuItem Header="CheckBoxVisibility">
<MenuItem Name="chkBoxVisible" Header="Visible" Click="top_Click"/>
<MenuItem Name="chkBoxCollapse" Header="Collapsed" Click="top_Click"/>
</MenuItem>
</MenuItem>
<MenuItem Header="Palette" Name="palette" >
<MenuItem Header="Metro" Name="metro" Click="top_Click"/>
<MenuItem Header="AutumnBrights" Name="autumn" Click="top_Click"/>
<MenuItem Header="FloraHues" Name="flora" Click="top_Click"/>
<MenuItem Header="PineApple" Name="pine" Click="top_Click"/>
<MenuItem Header="Elite" Name="elite" Click="top_Click"/>
<MenuItem Header="SandyBeach" Name="sandy" Click="top_Click"/>
<MenuItem Header="LightCandy" Name="light" Click="top_Click"/>
</MenuItem>
<MenuItem Header="Print" Name="print" Click="top_Click"/>
<MenuItem Header="Save" Name="Save" Click="top_Click"/>
<MenuItem Header="CrossHairBehavior" Name="enableCrossHair"
Click="top_Click">
</MenuItem>
</ContextMenu>
</chart:SfChart.ContextMenu>
</chart:SfChart>
|
private void top_Click(object sender, RoutedEventArgs e)
{
var header = (e.OriginalSource as MenuItem).Header.ToString();
switch(header)
{
case "Top":
(mainChart.Legend as sfchart.ChartLegend).DockPosition = sfchart.ChartDock.Top;
break;
case "Bottom":
(mainChart.Legend as sfchart.ChartLegend).DockPosition = sfchart.ChartDock.Bottom;
break;
case "Left":
(mainChart.Legend as sfchart.ChartLegend).DockPosition = sfchart.ChartDock.Left;
break;
case "Right":
(mainChart.Legend as sfchart.ChartLegend).DockPosition = sfchart.ChartDock.Right;
break;
case "Visible":
(mainChart.Legend as sfchart.ChartLegend).CheckBoxVisibility = Visibility.Visible;
break;
case "Collapsed":
(mainChart.Legend as sfchart.ChartLegend).CheckBoxVisibility = Visibility.Collapsed;
break;
case "Metro":
mainChart.Palette = sfchart.ChartColorPalette.Metro;
break;
case "AutumnBrights":
mainChart.Palette = sfchart.ChartColorPalette.AutumnBrights;
break;
case "FloraHues":
mainChart.Palette = sfchart.ChartColorPalette.FloraHues;
break;
case "PineApple":
mainChart.Palette = sfchart.ChartColorPalette.Pineapple;
break;
case "Elite":
mainChart.Palette = sfchart.ChartColorPalette.Elite;
break;
case "SandyBeach":
mainChart.Palette = sfchart.ChartColorPalette.SandyBeach;
break;
case "LightCandy":
mainChart.Palette = sfchart.ChartColorPalette.LightCandy;
break;
case "Print":
mainChart.Print();
break;
case "Save":
mainChart.Save("chart.png");
break;
case "CrossHairBehavior":
{
mainChart.Behaviors.Add(new sfchart.ChartCrossHairBehavior());
mainChart.PrimaryAxis.ShowTrackBallInfo = true;
mainChart.SecondaryAxis.ShowTrackBallInfo = true;
}
break;
default:
break;
}
} |