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

RadLegend - buggy rendering problem?

1 Answer 54 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Sam
Top achievements
Rank 1
Sam asked on 20 May 2013, 03:28 AM

Hi, I'm using a RadLegend, which is bound to a LegendItemCollection on my view model.

When I update the legend by regenerating the LegendItemCollection, I notice that the items render very briefly as "Telerik.Windows.Controls.Legend.LegendItem" before the item template is applied.

This is pretty annoying as it happens whenever the legend is updated, which is quite frequent for my current scenario.

I've looked at the default XAML and I think I've found the problem inside the RadLegend control template:

<ItemsControl ItemsPanel="{TemplateBinding ItemsPanel}" ItemsSource="{TemplateBinding Items}">
    <ItemsControl.ItemTemplate>
        <DataTemplate>
             <legend:LegendItemControl
             Content="{Binding}"
             ContentTemplate="{Binding ItemTemplate, RelativeSource={RelativeSource AncestorType=telerik:RadLegend}}"
             IsHovered="{Binding IsHovered, Mode=TwoWay}"
             VisualState="{Binding VisualState}" />
        </DataTemplate>
    </ItemsControl.ItemTemplate>
</ItemsControl>

The issue is with the ContentTemplate binding - if I set ContentTemplate to a static resource instead, then the rendering glitch goes away completely. There is obviously a small execution delay required for the binding to update as it has to search the visual tree, whereas the content binding is applied immediately as the data context is already known.

I can work around this for now by modifying the control template and using a static resource.

It would be great if you could fix this within the control implementation though.

Thanks!

Sam

1 Answer, 1 is accepted

Sort by
0
Petar Marchev
Telerik team
answered on 21 May 2013, 12:26 PM
Hello Sam,

Thank you for this feedback. Indeed the legend flickers in the described set up. The reason for this is that the ContentTemplate binding relies on the LegedItemControl being in the visual tree and the binding kicks in at some point after the first layout pass. I will forward this to our developers. Currently I can suggest that you try this work around - create an implicit style targeting the LegendItemControl and use a Setter as suggested below:

<telerik:RadLegend.Resources>
 <Style TargetType="telerik:LegendItemControl">
  <Setter Property="ContentTemplate" Value="{Binding ItemTemplate, RelativeSource={RelativeSource AncestorType=telerik:RadLegend}}" />

I hope that this will avoid the flickering, let us know how it goes. I have updated you Telerik points as a sign of gratitude for taking out of your time and bringing this issue to our attention.

Kind regards,
Petar Marchev
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
ChartView
Asked by
Sam
Top achievements
Rank 1
Answers by
Petar Marchev
Telerik team
Share this question
or