Skip to main content

Microsoft Silverlight

Answered Question Charting Legend PositionRSS Feed

(0)

NotSoLight
NotSoLight

Member

Member

12 points

20 Posts

Charting Legend Position

How do I move the Legend from the right hand side of the chart to another postion? For example, horizontally across the botton...

Thanks.

y_makram
y_makram

Contributor

Contributor

6172 points

1,233 Posts

Re: Charting Legend Position

You can achieve that by modifying the control template of the cahrt control, below is the default template, by modifying grid row and column definitions, and the placement of the Legend, Title, PlotArea, ChartArea template part, you can customize the look of the control.

1            <Setter Property="Template">
2                <Setter.Value>
3                    <ControlTemplate TargetType="charting:Chart">
4                        <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="10">
5                            <Grid>
6                                <Grid.RowDefinitions>
7                                    <RowDefinition Height="Auto" />
8                                    <RowDefinition Height="*" />
9                                </Grid.RowDefinitions>
10   
11                               <datavis:Title Content="{TemplateBinding Title}" Style="{TemplateBinding TitleStyle}" />
12   
13                               <!-- Use a nested Grid to avoid possible clipping behavior resulting from ColumnSpan+Width=Auto -->
14                               <Grid Grid.Row="1" Margin="0,15,0,15">
15                                   <Grid.ColumnDefinitions>
16                                       <ColumnDefinition Width="*" />
17                                       <ColumnDefinition Width="Auto" />
18                                   </Grid.ColumnDefinitions>
19   
20                                   <datavis:Legend x:Name="Legend" Title="{TemplateBinding LegendTitle}" Style="{TemplateBinding LegendStyle}" Grid.Column="1" />
21   
22                                   <Grid x:Name="ChartArea" Style="{TemplateBinding ChartAreaStyle}">
23                                       <Grid x:Name="PlotArea" Style="{TemplateBinding PlotAreaStyle}">
24                                           <Grid x:Name="GridLinesContainer" />
25                                           <Grid x:Name="SeriesContainer" />
26                                           <Border Margin="0,0,0,0" BorderBrush="#FF919191" BorderThickness="1,1,1,0" />
27                                       </Grid>
28                                   </Grid>
29                               </Grid>
30                           </Grid>
31                       </Border>
32                   </ControlTemplate>
33               </Setter.Value>
34           </Setter>
 

Thanks
Yasser Makram
http://www.silverlightrecipes.com
_____
Dont forget to click "Mark as Answer" on the post that helped you. If your question has not been answered, please post a followup question.

Amanda Wang - MSFT
Amanda W...

All-Star

All-Star

17234 points

1,466 Posts

Answered Question

Re: Charting Legend Position

 Hi.

You can try to refer this thread:  http://silverlight.net/forums/p/50698/133274.aspx

Amanda Wang
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities