1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 //----------------------------------------------------------------
4 namespace System.Activities.Core.Presentation
6 using System.Activities.Presentation;
7 using System.Activities.Presentation.Model;
8 using System.Activities.Presentation.View;
10 static class SwitchTryCatchDesignerHelper
12 public static void MakeRootDesigner(WorkflowViewElement wve)
14 DesignerView designerView = wve.Context.Services.GetService<DesignerView>();
15 if (!wve.Equals(designerView.RootDesigner))
17 designerView.MakeRootDesigner(wve.ModelItem);
21 public static void MakeParentRootDesigner<TParentType>(WorkflowViewElement wve)
22 where TParentType : WorkflowViewElement
24 WorkflowViewElement view = FindParentDesigner<TParentType>(wve);
27 MakeRootDesigner(view);
31 static TParentType FindParentDesigner<TParentType>(WorkflowViewElement wve)
32 where TParentType : WorkflowViewElement
34 ModelItem parent = wve.ModelItem.Parent;
35 while (parent != null)
37 if (parent.View != null && parent.View is TParentType)
39 return (TParentType)parent.View;
41 parent = parent.Parent;