ModelItem 클래스

정의

편집 모델의 단일 항목을 나타냅니다. 항목은 복잡한 데이터 구조에서 색 또는 정수에 이르기까지의 임의 항목일 수 있습니다.

public ref class ModelItem abstract : System::ComponentModel::INotifyPropertyChanged
public abstract class ModelItem : System.ComponentModel.INotifyPropertyChanged
type ModelItem = class
    interface INotifyPropertyChanged
Public MustInherit Class ModelItem
Implements INotifyPropertyChanged
상속
ModelItem
파생
구현

예제

ModelItem 가리키는 개체의 씬 프록시로 간주할 수 있습니다. 먼저 간단한 개체를 정의 Animal 합니다.

public class Animal  
{  
    // simple property  
    public string Name { get; set; }  
    // complex property   
    public Location Residence { get; set; }   
    // list   
    public List<Animal> CloseRelatives { get; set; }  
    // dictionary  
    public Dictionary<string, object> Features { get; set; }   
}  

public class Location  
{  
    public string StreetAddress { get; set; }  
    public string City { get; set; }  
    public string State { get; set; }   
}  

그런 다음 해당 인스턴스 AnimalModelItem 그에 대 한 프록시를 만듭니다. 그런 다음를 호출 하 여 개체를 검색할 수 있습니다 GetCurrentValue . 다음 코드에서는에서 정의한 다른 속성을 사용 하는 방법도 보여 줍니다 ModelItem .

EditingContext ec = new EditingContext();  
var companion1 = new Animal { Name = "Houdini the parakeet" };  
var companion2 = new Animal { Name = "Groucho the fish" };  
var animal = new Animal   
   {  
      Name = "Sasha the pug",  
      Residence = new Location   
      {  
         StreetAddress = "123 Main Street",  
         City = "AnyTown",  
         State = "Washington"  
      },  
      Features = new Dictionary<string, object> {   
         {"noise", "snort" },  
         {"MeanTimeUntilNaps", TimeSpan.FromMinutes(15) }  
      },  
      CloseRelatives = new List<Animal> { companion1, companion2 }   
   };  
ModelTreeManager mtm = new ModelTreeManager(ec);  mtm.Load(animal);  
ModelItem mi = mtm.Root;  

//Testing other properties of the class  
ModelItem root = mtm.Root;  
Assert.IsTrue(root.GetCurrentValue() == animal, "GetCurrentValue() returns same object");  
Assert.IsTrue(root.ItemType == typeof(Animal),"ItemType describes the item");  
Assert.IsTrue(root.Parent == null,"root parent is null");  
Assert.IsTrue(root.Source == null, "root source is null");  
Assert.IsTrue(((List<Animal>)root.Properties["CloseRelatives"].ComputedValue)[0] == companion1,   
   "ComputedValue of prop == actual object");  
Assert.IsFalse(((List<Animal>)root.Properties["CloseRelatives"].ComputedValue)[0] == companion2,   
   "ComputedValue of prop == actual object");  
Assert.AreEqual(root.Properties["Residence"].  
   Value.  
   Properties["StreetAddress"].  
   Value.GetCurrentValue(), "123 Main Street", "get actual value back out");  
Assert.AreEqual(root, root.Properties["Residence"].Parent, "property points to owner");  
ModelItem location = root.Properties["Residence"].Value;  
Assert.AreEqual(root.Properties["Residence"], location.Source, "sources point to the right place");  

설명

컬렉션을 통해 항목의 속성에 액세스 하 Properties 고 속성의 값을 변경할 수 있습니다.

ModelItem 디자이너의 기본 데이터 모델에 대 한 래퍼입니다. 메서드를 통해 기본 모델에 액세스할 수 있습니다 GetCurrentValue .

참고

메서드에서 반환 된 개체를 변경 하면 GetCurrentValue 디자이너의 serialization 및 실행 취소 시스템에 의해 반영 되지 않습니다.

생성자

ModelItem()

ModelItem 클래스의 새 인스턴스를 만듭니다.

속성

Attributes

이 항목에서 선언된 특성을 가져옵니다.

Content

항목의 ContentPropertyAttribute를 가져오거나, 그렇지 않으면 null입니다.

ItemType

항목이 나타내는 개체의 형식을 가져옵니다.

Name

항목의 이름 또는 ID를 가져오거나 설정합니다.

Parent

이 항목의 부모인 항목을 가져옵니다.

Parents

이 항목의 모든 부모를 가져옵니다.

Properties

이 항목의 공용 속성을 가져옵니다.

Root

이 트리의 루트인 항목을 가져옵니다.

Source

이 값을 제공한 속성을 가져옵니다.

Sources

이 값을 보유하는 모든 속성을 가져옵니다.

View

이 항목을 그래픽으로 나타내는 DependencyObject를 가져옵니다.

메서드

BeginEdit()

디자이너의 편집 범위를 엽니다. 편집 범위를 연 후에는 트랜잭션을 완료하거나 되돌릴 때까지 모든 개체의 변경 내용이 모두 범위에 저장됩니다. 편집 범위는 중첩할 수 있지만 순서대로 커밋해야 합니다.

BeginEdit(Boolean)

디자이너의 편집 범위를 엽니다.

BeginEdit(String)

디자이너의 편집 범위를 엽니다. 편집 범위를 연 후에는 트랜잭션을 완료하거나 되돌릴 때까지 모든 개체의 변경 내용이 모두 범위에 저장됩니다. 편집 범위는 중첩할 수 있지만 순서대로 커밋해야 합니다.

BeginEdit(String, Boolean)

디자이너의 편집 범위를 엽니다.

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetCurrentValue()

ModelItem이 래핑하는 기본 모델 개체의 현재 값을 반환합니다.

GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

이 모델 항목에 포함된 기본 모델 개체의 문자열 표현을 반환합니다.

이벤트

PropertyChanged

INotifyPropertyChanged 구현 이 이벤트를 사용하여 모델 변경 내용을 수신할 수 있습니다. 이 매개 변수는 WPF의 데이터 바인딩 기능에서도 사용됩니다.

확장 메서드

Focus(ModelItem)

지정한 디자이너 항목에 키보드 포커스를 설정합니다.

Focus(ModelItem, Int32)

지정한 디자이너 항목에 키보드 포커스를 설정합니다.

GetEditingContext(ModelItem)

지정한 모델 항목의 편집 컨텍스트를 검색합니다.

GetModelPath(ModelItem)

지정한 모델 항목의 경로를 검색합니다.

IsParentOf(ModelItem, ModelItem)

지정한 첫 번째 디자이너 항목이 지정한 두 번째 디자이너 항목의 부모인지 여부를 나타내는 값을 반환합니다.

적용 대상