refreshing panelbar items

2 posts, 0 answers
  1. Kevin
    Kevin avatar
    1 posts
    Member since:
    Nov 2011

    Posted 31 Jan 2012 Link to this post

    hi,  i'm trying to load a panel dynamically.  after i create a new object in my Diagrams collection, i just want to empty the panel and reload.  am i even close to correct here?:

            private void LoadWorkflowsToPanelBar()
                var workflowsPanel = rpbTools.ChildrenOfType<RadPanelBarItem>().ElementAt(0);
                foreach (var sssWorkflowDiagram in Diagrams)  // Diagrams is a collection i keep elsewhere
                    RadPanelBarItem panelBarItem = new RadPanelBarItem();
                    StackPanel stackPanel = new StackPanel();
                    stackPanel.Orientation = Orientation.Horizontal;
                    Image image = CreateImage("../Images/workflow.png", "../Images/workflow.png", sssWorkflowDiagram.Name);
                    TextBlock textBlock = new TextBlock();
                    textBlock.Text = sssWorkflowDiagram.Name;

                    panelBarItem.Tag = sssWorkflowDiagram.Id;
                    panelBarItem.Header = stackPanel;
                    workflowsPanel.Items.Add(panelBarItem);  // error is here
    this works fine the first time through, but the second time it is called, it does not load correctly.  when i debug this code, the following exception is thrown when the loop gets around to my new diagram:

    {System.ArgumentException: Value does not fall within the expected range.
       at MS.Internal.XcpImports.MethodEx(IntPtr ptr, String name, CValue[] cvData)
       at MS.Internal.XcpImports.MethodPack(IntPtr objectPtr, String methodName, Object[] rawData)
       at MS.Internal.XcpImports.Collection_Add[T](PresentationFrameworkCollection`1 collection, Object value)
       at System.Windows.PresentationFrameworkCollection`1.AddImpl(Object value)
       at System.Windows.Controls.ItemCollection.AddImpl(Object value)
       at System.Windows.Controls.ItemCollection.AddInternal(Object value)
       at System.Windows.PresentationFrameworkCollection`1.Add(T value)
       at SafetySpaces.Prototype.Silverlight.WorkflowDesigner.LoadWorkflowsToPanelBar()
       at SafetySpaces.Prototype.Silverlight.WorkflowDesigner.GetAllWorkflowDiagramsQueryCompleted(LoadOperation`1 loadOperation)
       at System.ServiceModel.DomainServices.Client.DomainContext.<>c__DisplayClass13`1.<Load>b__11(LoadOperation lo)
       at System.ServiceModel.DomainServices.Client.LoadOperation.<>c__DisplayClass4`1.<Create>b__0(LoadOperation`1 arg)
       at System.ServiceModel.DomainServices.Client.LoadOperation`1.InvokeCompleteAction()
       at System.ServiceModel.DomainServices.Client.OperationBase.Complete(Object result)
       at System.ServiceModel.DomainServices.Client.LoadOperation.Complete(DomainClientResult result)
       at System.ServiceModel.DomainServices.Client.DomainContext.CompleteLoad(IAsyncResult asyncResult)
       at System.ServiceModel.DomainServices.Client.DomainContext.<>c__DisplayClass1b.<Load>b__17(Object )}


  2. Petar Mladenov
    Petar Mladenov avatar
    2882 posts

    Posted 03 Feb 2012 Link to this post

    Hello Kevin ,

     I believe this could be naming issue in SIlverlight (2 visual elements with equal names). Could you please check out this forum post and let us know if it helps you or not? Thank you in advance.

    Kind regards,
    Petar Mladenov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft R3 2016 release webinar banner
Back to Top