共用方式為


PresentationElement.ModelElement 屬性

取得或設定簡報項目相關聯的模型項目。

命名空間:  Microsoft.VisualStudio.Modeling.Diagrams
組件:  Microsoft.VisualStudio.Modeling.Sdk.Diagrams.11.0 (在 Microsoft.VisualStudio.Modeling.Sdk.Diagrams.11.0.dll 中)

語法

'宣告
Public Property ModelElement As ModelElement
public ModelElement ModelElement { get; set; }

屬性值

型別:Microsoft.VisualStudio.Modeling.ModelElement
簡報項目相關聯的模型元素。

備註

這個屬性的巡覽或建立PresentationViewsSubject網域模型項目之間的關係。

如果每個簡報項目是非通常是網域模型項目中,使用PresentationViewsSubject關聯性。 網域類別和衍生自 PresentationElement 類別之間的對應關係是由網域項目對應您設定 DSL 定義檔中定義的。

範例

如果您的 DSL 定義,在您定義網域類別ExampleElement ,會對應至圖案類別ExampleShape,那麼您可以撰寫下列程式碼:

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

若要從項目,瀏覽] 圖形,請直接使用 PresentationViewsSubject 關聯性。 到您的 DSL 了主要的自訂項目,除非是永遠不會對每個網域模型元件的多個簡報項目:

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

.NET Framework 安全性

請參閱

參考

PresentationElement 類別

Microsoft.VisualStudio.Modeling.Diagrams 命名空間

Subject

其他資源

如何定義網域指定的語言