Share via


PresentationElement.ModelElement Property

Gets or sets the model element that is associated with the presentation element.

Namespace:  Microsoft.VisualStudio.Modeling.Diagrams
Assembly:  Microsoft.VisualStudio.Modeling.Sdk.Diagrams.12.0 (in Microsoft.VisualStudio.Modeling.Sdk.Diagrams.12.0.dll)

Syntax

'Declaration
Public Property ModelElement As ModelElement
public ModelElement ModelElement { get; set; }
public:
property ModelElement^ ModelElement {
    ModelElement^ get ();
    void set (ModelElement^ value);
}
member ModelElement : ModelElement with get, set
function get ModelElement () : ModelElement 
function set ModelElement (value : ModelElement)

Property Value

Type: Microsoft.VisualStudio.Modeling.ModelElement
The model element that is associated with the presentation element.

Remarks

This property navigates or creates a PresentationViewsSubject relationship to a domain model element.

Each presentation element is usually associated with a domain model element, using the PresentationViewsSubject relationship. The correspondence between domain classes and classes derived from PresentationElement is defined by the Domain Element Map which you set in the DSL Definition file.

Examples

If in your DSL Definition, you defined a domain class ExampleElement that is mapped to a shape class ExampleShape, then you can write the following code:

ExampleShape shape = ...;
ExampleElement element = shape.ModelElement as ExampleElement;

To navigate from the element to the shape, use the PresentationViewsSubject relationship directly. Unless you have made major customizations to your DSL, there is never more than one presentation element for each domain model element:

ExampleElement element = ...;
ExampleShape  shape =  PresentationViewsSubject.GetPresentation(i).FirstOrDefault() as
ExampleShape;
if (shape != null) {...}

.NET Framework Security

See Also

Reference

PresentationElement Class

Microsoft.VisualStudio.Modeling.Diagrams Namespace

Subject

Other Resources

How to Define a Domain-Specific Language