3

When I explicitly set the width of the legend in a Visiblox chart I find that legend item text gets cut off instead of wrapping. For example,

<Style x:Key="LegendStyle" TargetType="{x:Type charts:Legend}">
    <Setter Property="Width" Value="200" />
</Style>

<charts:Chart Name="chart" LegendStyle="{StaticResource LegendStyle}" />

I know I can use the LegendTemplate property of the Chart control to provide a ControlTemplate for the Legend class. However, I am not sure how I would modify this to produce text wrapping in the child LegendItem controls. I am also not sure how I can modify the template used to draw the LegendItem controls to produce text wrapping. Is there a way to do this?

Abiel
  • 5,251
  • 9
  • 54
  • 74

1 Answers1

2

It might be easier to provide a LegendItemTemplate or a LegendItemStyle. These are dependency properties on the series type. You can get more information in the documentation under the "Styling and templating" section.

fros
  • 1
  • 1
  • 4
  • Thanks. Can you also give an example of how to bind within the LegendItemTemplate's ControlTemplate to the DataSeries.Title and the ChartSeries color? I'm having difficulty getting the right binding expression. – Abiel Jul 25 '11 at 20:54
  • I was able to get the title property (just "{Binding DataSeries.Title}") but I'm still not sure how to get the series color within the ControlTemplate. – Abiel Jul 25 '11 at 21:00
  • OK, I answered my last question as well: "{Binding LineStroke}". – Abiel Jul 25 '11 at 21:06