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)

public:
property ModelElement^ ModelElement {
	ModelElement^ get();
	void set(ModelElement^ value);
}

Property Value

Type: Microsoft.VisualStudio.Modeling::ModelElement^

The model element that is associated with the presentation element.

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.

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) {...}
Return to top
Show: