This is a migrated thread and some comments may be shown as answers.

Marker in RadLegendItemStyle is Vanished!

1 Answer 38 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Minseok Bang
Top achievements
Rank 1
Minseok Bang asked on 25 Jun 2010, 09:17 AM
I try to make RadLegendItemStyl with CheckBox.

RadLegendStyle is here.

<Style x:Key="ChartLegendStyle1" TargetType="Telerik_Windows_Controls_Charting: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,0,0,0"/>
   <Setter Property="BorderBrush" Value="{StaticResource LegendBorderBrush}"/>
   <Setter Property="BorderThickness" Value="1,1,1,1"/>
   <Setter Property="TitleFontWeight" Value="Bold"/>
            <Setter Property="LegendItemStyle" Value="{StaticResource ChartLegendItemStyle1}" />
   <Setter Property="Template">
    <Setter.Value>
     <ControlTemplate TargetType="Telerik_Windows_Controls_Charting: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" Width="Auto" Padding="0,0,0,2" Text="{Binding}" />
      </Grid>
     </DataTemplate>
    </Setter.Value>
   </Setter>
  </Style>


And RadLegendItemStyle is here

<Style x:Key="ChartLegendItemStyle1" 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" Data="" Height="16" Margin="0,0.328,0,-0.329" Style="{TemplateBinding ItemStyle}" Stretch="Fill" Width="16" UseLayoutRounding="False"/>
          <Path Data="" Fill="{StaticResource LegendItemMarkerMask}" Height="14" Margin="1,1.163,1,0.836" OpacityMask="{StaticResource LegendItemMarkerMaskOpacityMask}" Stretch="Fill" Stroke="{StaticResource LegendItemMarkerMaskStroke}" StrokeThickness="{StaticResource LegendItemMarkerMaskStrokeThickness}" Width="14" UseLayoutRounding="False"/>
          <Path Data="" Fill="{StaticResource LegendItemMarkerMask2}" Height="14" Margin="1,1.163,1,0.836" Stretch="Fill" Width="14" UseLayoutRounding="False"/>
          <TextBlock Grid.Column="1" Foreground="{TemplateBinding Foreground}" Margin="{TemplateBinding Margin}" Padding="{TemplateBinding Padding}" Text="{TemplateBinding Label}"/>
         </Grid>
        </ControlTemplate>
       </Setter.Value>
      </Setter>
     </Style>

MainPage.Xaml Source here,
<Grid x:Name="LayoutRoot" Background="White">
     <Telerik_Windows_Controls:RadChart Content="RadChart" x:Name="radChart1"
                                           LegendStyle="{StaticResource ChartLegendStyle1}"/>
     <Telerik_Windows_Controls_Charting:ChartLegendItem Margin="0,-37,0,0" VerticalAlignment="Top" Style="{StaticResource ChartLegendItemStyle1}" Width="113" Height="21" HorizontalAlignment="Left"/>
    </Grid>

Don't Displayed Code. Source is below!!
<Path x:Name="PART_LegendItemMarker" Data="" Height="16" Margin="0,0.328,0,-0.329" Style="{TemplateBinding ItemStyle}" Stretch="Fill" Width="16" UseLayoutRounding="False"/>
          <Path Data="" Fill="{StaticResource LegendItemMarkerMask}" Height="14" Margin="1,1.163,1,0.836" OpacityMask="{StaticResource LegendItemMarkerMaskOpacityMask}" Stretch="Fill" Stroke="{StaticResource LegendItemMarkerMaskStroke}" StrokeThickness="{StaticResource LegendItemMarkerMaskStrokeThickness}" Width="14" UseLayoutRounding="False"/>
          <Path Data="" Fill="{StaticResource LegendItemMarkerMask2}" Height="14" Margin="1,1.163,1,0.836" Stretch="Fill" Width="14" UseLayoutRounding="False"/>


CheckBox and TextBlock is displayed but Marker is not displayed

What Can I do?

LegendItem Marker is vanished in LegendItemStyle When I try to fix LegendItemStyle.

1 Answer, 1 is accepted

Sort by
0
Sia
Telerik team
answered on 29 Jun 2010, 02:21 PM
Hi Minseok Bang,

You have empty data in your paths and that is why they disappear when you retemplate the ChartLegendItems. Please check the xaml file, which I have attached.

After reviewing it you can replace the three paths with whatever you need. For example you can have:

<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>
                            <CheckBox />
                            <TextBlock Grid.Column="1"
                                       Foreground="{TemplateBinding Foreground}"
                                       Margin="{TemplateBinding Margin}"
                                       Padding="{TemplateBinding Padding}"
                                       Text="{TemplateBinding Label}"/>
                    </Grid>
               </ControlTemplate>
          </Setter.Value>
     </Setter>
</Style>

It this approach doesn't work in your project, I need to know the version of your Telerik controls in order to be able to help you.

Greetings,
Sia
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Chart
Asked by
Minseok Bang
Top achievements
Rank 1
Answers by
Sia
Telerik team
Share this question
or