RadLegend - buggy rendering problem?

2 posts, 0 answers
  1. Sam
    Sam avatar
    67 posts
    Member since:
    Jun 2011

    Posted 19 May 2013 Link to this post

    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}">
                 ContentTemplate="{Binding ItemTemplate, RelativeSource={RelativeSource AncestorType=telerik:RadLegend}}"
                 IsHovered="{Binding IsHovered, Mode=TwoWay}"
                 VisualState="{Binding VisualState}" />

    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.


  2. Petar Marchev
    Petar Marchev avatar
    968 posts

    Posted 21 May 2013 Link to this post

    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:

     <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.

  3. DevCraft banner
Back to Top