Skip to main content
Home Forums Silverlight Programming Silverlight Controls and Silverlight Toolkit Charting Legend Position
2 replies. Latest Post by Amanda Wang - MSFT on December 2, 2008.
(0)
NotSoLight
Member
12 points
20 Posts
11-29-2008 10:21 PM |
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
Contributor
6172 points
1,233 Posts
11-30-2008 5:25 AM |
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>
Amanda W...
All-Star
17241 points
1,466 Posts
12-02-2008 3:06 AM |
Hi.
You can try to refer this thread: http://silverlight.net/forums/p/50698/133274.aspx