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

Adding combobox in chart legend

1 Answer 34 Views
Chart
This is a migrated thread and some comments may be shown as answers.
rahul
Top achievements
Rank 1
rahul asked on 12 Jul 2011, 01:54 PM
Is it possible to add the combo box in Chart Legend? Can somebody please post the code snippet



Thanks,
Rahul

1 Answer, 1 is accepted

Sort by
0
Evgenia
Telerik team
answered on 14 Jul 2011, 12:12 PM
Hi Rahul,

You can review our demo where the ChartLegendItem-s are retemplated so that a Check-box is added. You can use the approach and add your ComboBox in the Legend style. This is the default Legend Style that you may customize:

<Style  TargetType="telerikCharting: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="BorderBrush" Value="{StaticResource LegendBorderBrush}" />
       <Setter Property="BorderThickness" Value="{StaticResource LegendBorderThickness}" />
       <Setter Property="HeaderFontWeight" Value="Bold" />
       <Setter Property="HorizontalContentAlignment" Value="Stretch" />
       <Setter Property="VerticalContentAlignment" Value="Stretch" />
       <Setter Property="LegendItemMarkerShape" Value="{StaticResource LegendItemMarkerShape}" />
       <Setter Property="Template" >
           <Setter.Value>
               <ControlTemplate TargetType="telerikCharting: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 Foreground="{TemplateBinding Foreground}"
                                           HorizontalAlignment="Stretch"
                                           HorizontalContentAlignment="Stretch"
                                           FontWeight="{TemplateBinding HeaderFontWeight}" 
                                           Content="{TemplateBinding Header}" 
                                           ContentTemplate="{TemplateBinding HeaderTemplate}"/>
                           <ItemsPresenter Grid.Row="1"
                                           HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                           VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                       </Grid>
                   </Border>
               </ControlTemplate>
           </Setter.Value>
       </Setter>
       <Setter Property="ItemsPanel">
           <Setter.Value>
               <ItemsPanelTemplate>
                   <telerikControls:RadWrapPanel>
                   </telerikControls:RadWrapPanel>
               </ItemsPanelTemplate>
           </Setter.Value>
       </Setter>
       <Setter Property="HeaderTemplate">
           <Setter.Value>
               <DataTemplate>
                   <Grid>
                       <TextBlock FontSize="12"
                                  Padding="0,0,0,2"  
                                  Width="Auto" 
                                  Height="Auto" 
                                  Text="{Binding}"
                                  Visibility="{Binding Converter={StaticResource textToVisibilityConverter}}"
                                  TextWrapping="Wrap" />
                   </Grid>
               </DataTemplate>
           </Setter.Value>
       </Setter>
   </Style>

Greetings,
Evgenia
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
Chart
Asked by
rahul
Top achievements
Rank 1
Answers by
Evgenia
Telerik team
Share this question
or