Jump to content
Software FX Community

Positioning the legend


nabils

Recommended Posts

How do I position the legend? The help docs mention a property of legendbox called Dock to allow you to dock the legend around the chart but I cannot find this. I need to display the legend at the top of the chart and make the items flow horizontally rather than vertically?

 Is this possible?

Link to comment
Share on other sites

Inside the chart we use a DockPanel - actually a very similar panel - to layout the different tools (LegendBox, DataView). Because of this you can get the legend at the top of the chart by doing this in XAML

<

cfx:Chart.LegendBox><cfx:LegendBox Visibility="Visible" DockPanel.Dock="Top" /></cfx:Chart.LegendBox>

or in code

DockPanel

.SetDock(chart1.LegendBox, Dock.Top);

Regards,

JuanC

Link to comment
Share on other sites

Our current builds will do that automatically, you can also setup your own panel by using the LegendBox.ContainerStyle property with a style as follows

<

Style x:Key="MyLegendStyle" TargetType="{x:Type ItemsControl}"><Setter Property="Template"><Setter.Value><ControlTemplate><StackPanel Orientation="Horizontal" IsItemsHost="True"/></ControlTemplate></Setter.Value></Setter></Style>

Regards,

JuanC

Link to comment
Share on other sites

  • 1 year later...

When I define this style in a default Chart's resources (a chart that has no data set), it doesn't seem to apply it.

<cfx:Chart>

<cfx:Chart.Resources>

<Style x:Key="{x:Type ItemsControl}" TargetType="{x:Type ItemsControl}">

...

I changed the key so that it would be the default style for any ItemsControl. Is there something else I should be doing? Also, if I define this style in XAML in a global resource dictionary in my application, how would I apply it in code?

Thank you,

Mick

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...