Hi there,
I tried to restyle the legend of my chart area.
I have two styles to define. First one is, that the legend only appears when a togglebutton (outside of the chart) is clicked. The legend position is over the whole size of the chart. For this reason i override the chart template as follows:
The second style is, that the legend is placed between the title and the chartarea.
Therefore i override the chart template and set the legendstyle to the chart:
Everything works fine except the height of the legend. In both cases the height is filled to any fixed size. I want to set the height of the legend to auto that it just uses the space it needs. Therefore I tried to override the VerticalAlignment to Center as the MinHeight to 100 but nothing seems to be working.
Maybe this is the same issue I have with the size of the chart it self. I am not able to stlye the view that contains the chart that it shrinks with the window. Growing seems to have no problem but shrinking is not possible. (Defaultsize of the chart is around 600x800)
I tried to restyle the legend of my chart area.
I have two styles to define. First one is, that the legend only appears when a togglebutton (outside of the chart) is clicked. The legend position is over the whole size of the chart. For this reason i override the chart template as follows:
<ControlTemplate x:Key="_chartControlTemplate" TargetType="{x:Type telerik:RadChart}"> |
<Grid Background="{TemplateBinding Background}"> |
<Grid x:Name="PART_DefaultLayoutGrid"> |
<Grid.ColumnDefinitions> |
<ColumnDefinition Width="Auto"/> |
</Grid.ColumnDefinitions> |
<Grid.RowDefinitions> |
<RowDefinition Height="Auto"/> |
<RowDefinition Height="*"/> |
</Grid.RowDefinitions> |
<ContentPresenter x:Name="PART_DefaultChartTitleContainer" Grid.Column="0" Grid.Row="0" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" ContentTemplate="{TemplateBinding ContentTemplate}"/> |
<ContentPresenter x:Name="PART_DefaultChartAreaContainer" Grid.Column="0" Grid.Row="1" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" ContentTemplate="{TemplateBinding ContentTemplate}"/> |
<ContentPresenter x:Name="PART_DefaultChartLegendContainer" Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" Visibility="{Binding ElementName=LegendVisibilityButton, Path=IsChecked, Converter={StaticResource legendConverter}}"/> |
</Grid> |
<ContentPresenter Height="Auto" Width="Auto" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" ContentTemplate="{TemplateBinding ContentTemplate}"/> |
</Grid> |
</ControlTemplate> |
The second style is, that the legend is placed between the title and the chartarea.
Therefore i override the chart template and set the legendstyle to the chart:
<Style x:Key="_chartLegendStyle" TargetType="{x:Type telerik:ChartLegend}"> |
||||||||||||||||||
<Setter Property="Template"> | ||||||||||||||||||
. | ||||||||||||||||||
. | ||||||||||||||||||
. | ||||||||||||||||||
<Setter.Value> | ||||||||||||||||||
<Setter Property="ItemsPanel"> | ||||||||||||||||||
<Setter.Value> | ||||||||||||||||||
<ItemsPanelTemplate > | ||||||||||||||||||
<StackPanel IsItemsHost="True" Orientation="Horizontal"/> | ||||||||||||||||||
</ItemsPanelTemplate> | ||||||||||||||||||
</Setter.Value> | ||||||||||||||||||
</Setter> | ||||||||||||||||||
<Setter Property="HeaderTemplate"> | ||||||||||||||||||
. | ||||||||||||||||||
. | ||||||||||||||||||
. | ||||||||||||||||||
</Setter> | ||||||||||||||||||
</Style> |
Everything works fine except the height of the legend. In both cases the height is filled to any fixed size. I want to set the height of the legend to auto that it just uses the space it needs. Therefore I tried to override the VerticalAlignment to Center as the MinHeight to 100 but nothing seems to be working.
Maybe this is the same issue I have with the size of the chart it self. I am not able to stlye the view that contains the chart that it shrinks with the window. Growing seems to have no problem but shrinking is not possible. (Defaultsize of the chart is around 600x800)