This question is locked. New answers and comments are not allowed.
Hi,
I am adding a custom style to the ChartLegendItem:
I am adding a custom style to the ChartLegendItem:
| <SolidColorBrush x:Key="LegendForeground" |
| Color="#FF000000" /> |
| <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="LegendItemMarkerMaskStroke" |
| Color="White" /> |
| <System:Double x:Key="LegendItemMarkerMaskStrokeThickness">1</System:Double> |
| <SolidColorBrush x:Key="LegendItemMarkerMaskOpacityMask" |
| Color="#FF000000" /> |
| <SolidColorBrush x:Key="LegendItemMarkerMask2" |
| Color="Transparent" /> |
| <Style x:Key="TrimmedChartLegendItem" |
| TargetType="Telerik_Windows_Controls_Charting: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_Windows_Controls_Charting:ChartLegendItem"> |
| <Grid HorizontalAlignment="Stretch" |
| VerticalAlignment="Top"> |
| <Grid.ColumnDefinitions> |
| <ColumnDefinition Width="Auto" /> |
| <ColumnDefinition /> |
| </Grid.ColumnDefinitions> |
| <Path x:Name="PART_LegendItemMarker" |
| Stretch="Fill" |
| Height="16" |
| Margin="{TemplateBinding Margin}" |
| Style="{TemplateBinding ItemStyle}" |
| Width="16" |
| Data="" /> |
| <Path Fill="{StaticResource LegendItemMarkerMask}" |
| Stretch="Fill" |
| Stroke="{StaticResource LegendItemMarkerMaskStroke}" |
| StrokeThickness="{StaticResource LegendItemMarkerMaskStrokeThickness}" |
| Height="14" |
| Margin="{TemplateBinding Margin}" |
| Width="14" |
| OpacityMask="{StaticResource LegendItemMarkerMaskOpacityMask}" |
| Data="" /> |
| <Path Fill="{StaticResource LegendItemMarkerMask2}" |
| Stretch="Fill" |
| Height="14" |
| Margin="{TemplateBinding Margin}" |
| Width="14" |
| Data="" /> |
| <TextBlock Margin="{TemplateBinding Margin}" |
| Grid.Column="1" |
| Foreground="{TemplateBinding Foreground}" |
| Width="140" |
| Padding="{TemplateBinding Padding}" |
| Text="{TemplateBinding Label}"> |
| <Interactivity:Interaction.Behaviors> |
| <Behaviors:EllipsisTextBlockBehavior /> |
| </Interactivity:Interaction.Behaviors> |
| </TextBlock> |
| </Grid> |
| </ControlTemplate> |
| </Setter.Value> |
| </Setter> |
| </Style> |
I'm getting the customizations to the TextBlock, etc. but I am losing the Legend Item Shape from the display. Any Ideas?
I refer to the above style via:
| <Style x:Key="chartLegendStyle" |
| TargetType="Telerik_Windows_Controls_Charting:ChartLegend"> |
| <Setter Property="Foreground" |
| Value="#00000000" /> |
| <Setter Property="Background" |
| Value="#00000000" /> |
| <Setter Property="Padding" |
| Value="10,10,10,5" /> |
| <Setter Property="Margin" |
| Value="0,0,20,0" /> |
| <Setter Property="BorderBrush" |
| Value="#00000000" /> |
| <Setter Property="BorderThickness" |
| Value="1,1,1,1" /> |
| <Setter Property="TitleFontWeight" |
| Value="Bold" /> |
| <Setter Property="MaxWidth" |
| Value="200" /> |
| <Setter Property="LegendItemStyle" |
| Value="{StaticResource TrimmedChartLegendItem}" /> |
| <Setter Property="Template"> |
| <Setter.Value> |
| <ControlTemplate TargetType="Telerik_Windows_Controls_Charting:ChartLegend"> |
| <Border Background="{TemplateBinding Background}" |
| BorderBrush="{TemplateBinding BorderBrush}" |
| BorderThickness="{TemplateBinding BorderThickness}"> |
| <Grid Margin="{TemplateBinding Padding}"> |
| <Grid.RowDefinitions> |
| <RowDefinition Height="Auto" /> |
| <RowDefinition Height="*" /> |
| </Grid.RowDefinitions> |
| <ContentControl FontWeight="{TemplateBinding TitleFontWeight}" |
| Foreground="{TemplateBinding Foreground}" |
| Content="{TemplateBinding Header}" |
| ContentTemplate="{TemplateBinding HeaderTemplate}" /> |
| <ItemsPresenter Grid.Row="1" /> |
| </Grid> |
| </Border> |
| </ControlTemplate> |
| </Setter.Value> |
| </Setter> |
| <Setter Property="ItemsPanel"> |
| <Setter.Value> |
| <ItemsPanelTemplate> |
| <StackPanel Orientation="{Binding ItemsPanelOrientation}" |
| Width="200" /> |
| </ItemsPanelTemplate> |
| </Setter.Value> |
| </Setter> |
| <Setter Property="HeaderTemplate"> |
| <Setter.Value> |
| <DataTemplate> |
| <Grid> |
| <TextBlock Height="Auto" |
| TextWrapping="Wrap" |
| HorizontalAlignment="Left" |
| Width="Auto" |
| FontSize="12" |
| Padding="0,0,0,2" |
| Text="{Binding}" /> |
| </Grid> |
| </DataTemplate> |
| </Setter.Value> |
| </Setter> |
| </Style> |
If I comment out the line below:
| <Setter Property="LegendItemStyle" |
| Value="{StaticResource TrimmedChartLegendItem}" /> |
The legend item shape appears as expected.
Any ideas?