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

Dynamic assignment of LabelTemplate gives exception

1 Answer 29 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Anthony
Top achievements
Rank 1
Anthony asked on 15 Feb 2014, 06:59 PM
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

1 Answer, 1 is accepted

Sort by
0
Rosy Topchiyska
Telerik team
answered on 19 Feb 2014, 04:52 PM
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.
Tags
Chart
Asked by
Anthony
Top achievements
Rank 1
Answers by
Rosy Topchiyska
Telerik team
Share this question
or