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

LegendStyle Not Set from Resource Dictionary

1 Answer 48 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Jeremy Miller
Top achievements
Rank 1
Jeremy Miller asked on 25 Aug 2010, 09:12 PM
I have a resource dictionary with the entry:
<Style x:Key="legendStyle" TargetType="telerikCharting:ChartLegend">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="telerikCharting:ChartLegend">
                    <Grid Visibility="Collapsed" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
</Style>

In one file.  I reference this file from my App.xaml file like so:
<Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary x:Name="Ventana.Vantage.Silverlight.Res-Colors" Source="/Ventana.Vantage.Silverlight.Res;component/Styles/Colors.xaml"/>
                <ResourceDictionary x:Name="PortletStyles" Source="Portlets/PortletStyles.xaml"></ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>

Now in the file where I want to use the style, I have it referenced like this:
<telerik:RadChart x:Name="chart" ItemsSource="{Binding Series.Cells}" Grid.Row="1" Margin="0 5 0 0" BorderThickness="0"
                              Style="{StaticResource SmallFont}" LegendStyle="{StaticResource legendStyle}">

This, seemingly straight-forward solution produces no results as for every chart I have, the legend is visible.  The only way to make this work was to use code-behind, but I'd like to not have to do that.  Is this a Telerik bug (because I don't mind filing it) or some mistake on my part?

1 Answer, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 30 Aug 2010, 09:43 AM
Hello Jeremy Miller,

Unfortunately I wasn't able to reproduce this behavior. Using styles from ResourceDictionary successfully styles the RadChart. Here's what I have done:
  1. I used your style and put it in a new ResourceDictionary named Dictionary1.xaml placed in the application root folder.
  2. I registered the dictionary in App.xaml like this:
  3. <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Dictionary1.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
  4. I used the style the same way you did and it was applied.

I have attached a sample application that demonstrates this scenario.

Can you please check if there are any errors in the Output window of VisualStudio and upload a sample application demonstrating your issue so that we can further assist you?

Regards,
Yavor Ivanov
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
Jeremy Miller
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Share this question
or