This question is locked. New answers and comments are not allowed.
Hi,
I'm trying to simply have my chart's legend items wrap their text, rather than being cuttoff.
Pretty basic thing really. I was surprised to hear how complicated it was to do this. I followed the instructions at http://www.telerik.com/help/silverlight/radchart-styling-and-appearance-styling-chart-legend.html, but I'm getting an error before I even change anything. As soon as I set the LegendItemStyle in the ChartLegendStyle via a setter, Visual Studio underlines the whole line in blue squigly, and holding the mouse over the squigly yields the error message: "Catastrophic Failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED)).
Here is my code. I chose to edit the style in a copy, stored in App.xaml.
I'm trying to simply have my chart's legend items wrap their text, rather than being cuttoff.
Pretty basic thing really. I was surprised to hear how complicated it was to do this. I followed the instructions at http://www.telerik.com/help/silverlight/radchart-styling-and-appearance-styling-chart-legend.html, but I'm getting an error before I even change anything. As soon as I set the LegendItemStyle in the ChartLegendStyle via a setter, Visual Studio underlines the whole line in blue squigly, and holding the mouse over the squigly yields the error message: "Catastrophic Failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED)).
Here is my code. I chose to edit the style in a copy, stored in App.xaml.
<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:System="clr-namespace:System;assembly=mscorlib" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" x:Class="GarciaCharts.App" > <Application.Resources> <SolidColorBrush x:Key="LegendForeground" Color="#FF000000"/> <LinearGradientBrush x:Key="LegendBackground" EndPoint="1.96,0.5" StartPoint="-0.96,0.5"> <GradientStop Color="#FF0000FF"/> <GradientStop Color="#FFF0F0F0" Offset="0.5"/> </LinearGradientBrush> <SolidColorBrush x:Key="LegendBorderBrush" Color="#FF848484"/> <Thickness x:Key="LegendBorderThickness">1</Thickness> <telerik:TextToVisibilityConverter x:Key="textToVisibilityConverter"/> <Style x:Key="ChartLegendStyle1" TargetType="telerik:ChartLegend"> <Setter Property="Foreground" Value="{StaticResource LegendForeground}"/> <Setter Property="Background" Value="{StaticResource LegendBackground}"/> <Setter Property="Padding" Value="10,10,10,5"/> <Setter Property="Margin" Value="0"/> <Setter Property="LegendItemStyle" Value="{StaticResource ChartLegendItemStyle1}"/> <Setter Property="BorderBrush" Value="{StaticResource LegendBorderBrush}"/> <Setter Property="BorderThickness" Value="{StaticResource LegendBorderThickness}"/> <Setter Property="TitleFontWeight" Value="Bold"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="telerik:ChartLegend"> <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}"> <Grid Margin="{TemplateBinding Padding}"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <ContentControl ContentTemplate="{TemplateBinding HeaderTemplate}" Content="{TemplateBinding Header}" Foreground="{TemplateBinding Foreground}" FontWeight="{TemplateBinding TitleFontWeight}"/> <ItemsPresenter Grid.Row="1"/> </Grid> </Border> </ControlTemplate> </Setter.Value> </Setter> <Setter Property="ItemsPanel"> <Setter.Value> <ItemsPanelTemplate> <telerik:RadWrapPanel Orientation="{Binding ItemsPanelOrientation}"/> </ItemsPanelTemplate> </Setter.Value> </Setter> <Setter Property="HeaderTemplate"> <Setter.Value> <DataTemplate> <Grid> <TextBlock FontSize="12" HorizontalAlignment="Left" Height="Auto" Padding="0,0,0,2" TextWrapping="Wrap" Text="{Binding}" Visibility="{Binding Converter={StaticResource textToVisibilityConverter}}" Width="Auto"/> </Grid> </DataTemplate> </Setter.Value> </Setter> </Style> <LinearGradientBrush x:Key="LegendItemMarkerMask" EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="#D8FFFFFF" Offset="0.009"/> <GradientStop Color="#66FFFFFF" Offset="1"/> <GradientStop Color="Transparent" Offset="0.43"/> <GradientStop Color="#7FFFFFFF" Offset="0.42"/> </LinearGradientBrush> <SolidColorBrush x:Key="LegendItemMarkerMaskOpacityMask" Color="#FF000000"/> <SolidColorBrush x:Key="LegendItemMarkerMaskStroke" Color="White"/> <System:Double x:Key="LegendItemMarkerMaskStrokeThickness">1</System:Double> <SolidColorBrush x:Key="LegendItemMarkerMask2" Color="Transparent"/> <Style x:Key="ChartLegendItemStyle1" TargetType="telerik:ChartLegendItem"> <Setter Property="Foreground" Value="{StaticResource LegendForeground}"/> <Setter Property="Padding" Value="5,0,5,0"/> <Setter Property="Margin" Value="0,3,0,2"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="telerik:ChartLegendItem"> <Grid x:Name="PART_MainContainer" HorizontalAlignment="Stretch" VerticalAlignment="Top"> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition/> </Grid.ColumnDefinitions> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="HoverStates"> <VisualState x:Name="Normal"> <Storyboard> <DoubleAnimation Duration="0.00:00:00.15" To="1.0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PART_MainContainer"/> </Storyboard> </VisualState> <VisualState x:Name="Hovered"> <Storyboard> <DoubleAnimation Duration="0.00:00:00.15" To="1.0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PART_MainContainer"/> </Storyboard> </VisualState> <VisualState x:Name="Hidden"> <Storyboard> <DoubleAnimation Duration="0.00:00:00.15" To="0.15" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PART_MainContainer"/> </Storyboard> </VisualState> </VisualStateGroup> <VisualStateGroup x:Name="SelectionStates"> <VisualState x:Name="Unselected"/> <VisualState x:Name="Selected"> <Storyboard> <ObjectAnimationUsingKeyFrames Duration="0.00:00:00.05" Storyboard.TargetProperty="Stroke" Storyboard.TargetName="PART_LegendItemMarker"> <DiscreteObjectKeyFrame KeyTime="0.00:00:00.0"> <DiscreteObjectKeyFrame.Value> <SolidColorBrush Color="#B2000000"/> </DiscreteObjectKeyFrame.Value> </DiscreteObjectKeyFrame> </ObjectAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames Duration="0.00:00:00.05" Storyboard.TargetProperty="StrokeThickness" Storyboard.TargetName="PART_LegendItemMarker"> <DiscreteObjectKeyFrame KeyTime="0.00:00:00.0"> <DiscreteObjectKeyFrame.Value> <System:Double>2</System:Double> </DiscreteObjectKeyFrame.Value> </DiscreteObjectKeyFrame> </ObjectAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames Duration="0.00:00:00.05" Storyboard.TargetProperty="StrokeThickness" Storyboard.TargetName="PART_SelectedState"> <DiscreteObjectKeyFrame KeyTime="0.00:00:00.0"> <DiscreteObjectKeyFrame.Value> <System:Double>0</System:Double> </DiscreteObjectKeyFrame.Value> </DiscreteObjectKeyFrame> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> <Path x:Name="PART_LegendItemMarker" Data="" Height="16" Margin="{TemplateBinding Margin}" Style="{TemplateBinding ItemStyle}" Stretch="Fill" StrokeThickness="{TemplateBinding MarkerStrokeThickness}" Width="16"/> <Path x:Name="PART_SelectedState" Data="" Fill="{StaticResource LegendItemMarkerMask}" Height="14" Margin="{TemplateBinding Margin}" OpacityMask="{StaticResource LegendItemMarkerMaskOpacityMask}" Stretch="Fill" Stroke="{StaticResource LegendItemMarkerMaskStroke}" StrokeThickness="{StaticResource LegendItemMarkerMaskStrokeThickness}" Width="14"/> <Path Data="" Fill="{StaticResource LegendItemMarkerMask2}" Height="14" Margin="{TemplateBinding Margin}" Stretch="Fill" Width="14"/> <TextBlock x:Name="PART_TextBlock" Grid.Column="1" Foreground="{TemplateBinding Foreground}" Margin="{TemplateBinding Margin}" Padding="{TemplateBinding Padding}" Text="{TemplateBinding Label}"/> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> </Application.Resources> </Application>