Dynamic assignment of LabelTemplate gives exception

2 posts, 0 answers
  1. Anthony
    Anthony avatar
    3 posts
    Member since:
    Jan 2013

    Posted 15 Feb 2014 Link to this post

    Hi

    I'm trying to programmatically assign the Axis.LabelTemplate property during run time and receive the ArgumentOutOfRangeException.

    After decompiling Telerik.Windows.Controls.PresenterBase it appears that the exception is occurring when the ClearPresenters() method is called.

    The line containing "this.renderSurface.Children.Remove(elements[i] as UIElement);" is attempting to access an item that was removed in the line preceding it.

            internal void ClearPresenters(IList elements)
            {
                if (this.renderSurface == null)
                {
                    elements.Clear();
                }
                else
                {
                    for (int i = elements.Count - 1; i >= 0; i--)
                    {
                       elements.RemoveAt(i);
                       this.renderSurface.Children.Remove(elements[i] as UIElement);
                    }
                    this.Invalidate();
                }
            }

    Is there another way to programmatically assign this value.  I tried using a DataTemplateSelector, however, received a similar error message as it too calls the ClearPresenters method.

    Thanks,
    Ant
  2. Rosy Topchiyska
    Admin
    Rosy Topchiyska avatar
    550 posts

    Posted 19 Feb 2014 Link to this post

    Hello Anthony,

    Thank you for contacting us.

    From the provided information it is not completely clear how you assign the LabelTemplate property. I have attached a project that demonstrates how to set a LabelTemplate runtime. Could you please take a look and see if this works for you. If not, could you please modify it in order to reproduce the error.

    I look forward to your reply. 

    Regards,
    Rositsa Topchiyska
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peek previews directly from the developers working on the UI for Windows Phone, subscribe to the blog feed now.
  3. DevCraft banner
Back to Top