Page view counter
Charting Legend Position Subscribe to this thread
Last post 12-02-2008 3:06 AM by Amanda Wang - MSFT. 2 replies.
Sort Posts:
11-29-2008 10:21 PM
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.

NotSoLight

Loading...
Joined on 11-29-2008
Posts 20
11-30-2008 5:25 AM
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.

y_makram

Loading...
Joined on 06-07-2007
Cairo, Egypt
Posts 1,218
12-02-2008 3:06 AM
Marked as Answer
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.

Amanda Wang - MSFT

Loading...
Joined on 04-30-2007
Posts 1,015
Microsoft Communities