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

refreshing panelbar items

1 Answer 57 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Kevin
Top achievements
Rank 1
Kevin asked on 01 Feb 2012, 03:36 AM
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);
            workflowsPanel.Items.Clear();
            
            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;
                stackPanel.Children.Add(image);
                stackPanel.Children.Add(textBlock);

                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 )}


thanks,

kevin

1 Answer, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 03 Feb 2012, 02:39 PM
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 >>

Tags
PanelBar
Asked by
Kevin
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Share this question
or