Jump to content
Software FX Community

Positioning the legend


nabils

Recommended Posts

Posted

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?

Posted

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

Posted

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

Posted

The legend seems to position itself underneath the title when using DockPanel.Top. Can I get them on the same line? Title on the left and legend on the right.

  • 1 year later...
Posted

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

Archived

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

×
×
  • Create New...