This question is locked. New answers and comments are not allowed.
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()
{
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
}
{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
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