PresentationViewsSubject::GetPresentation Method (ModelElement^)
Visual Studio 2015
Gets the PresentationElements that display a given domain model element.
Assembly: Microsoft.VisualStudio.Modeling.Sdk.Diagrams.12.0 (in Microsoft.VisualStudio.Modeling.Sdk.Diagrams.12.0.dll)
public: static LinkedElementCollection<PresentationElement^>^ GetPresentation( ModelElement^ element )
Parameters
- element
- Type: Microsoft.VisualStudio.Modeling::ModelElement^
Return Value
Type: Microsoft.VisualStudio.Modeling::LinkedElementCollection<PresentationElement^>^Use this method to navigate from a domain model element or relationship to the shape or link that represents it in the user interface. Unless you have made a major customization to the DSL, there will be one presentation element for each domain element. In some cases while the display is being initialized, there might be no display element. There will be no display element if you have not set a Domain Element Mapping for the domain class in your DSL Definition.
For a specific class of domain element, the Domain Element Mapping specifies the class of the presentation element – a shape or link.
ExampleElement element = ...;
ExampleShape shape = PresentationViewsSubject.GetPresentation(element).FirstOrDefault() as ExampleShape;
if (shape != null) {...}
// A domain relationship:
ExampleElementReferencesTargets relationship = ...;
// In the DSL Definition, this relationship is mapped to the following BinaryLinkShape:
ExampleConnector link = PresentationViewsSubject.GetPresentation(relationship).FirstOrDefault() as ExampleConnector;
if (link != null) {...}
Show: