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; }
}

둘째, 해당 인스턴스와 ModelItem 해당 Animal 인스턴스에 대한 프록시를 만듭니다. 그런 다음, 개체를 호출 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 항목의 속성에 액세스하고 속성 값을 변경할 수 있습니다.

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

메모

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

생성자

Name Description
ModelItem()

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

속성

Name Description
Attributes

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

Content

항목 ContentPropertyAttribute또는 null .

ItemType

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

Name

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

Parent

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

Parents

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

Properties

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

Root

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

Source

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

Sources

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

View

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

메서드

Name Description
BeginEdit()

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

BeginEdit(Boolean)

디자이너에 대한 편집 범위를 엽니다.

BeginEdit(String, Boolean)

디자이너에 대한 편집 범위를 엽니다.

BeginEdit(String)

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

Equals(Object)

지정한 개체와 현재 개체가 같은지 여부를 확인합니다.

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

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

GetHashCode()

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

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

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

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

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

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

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

이벤트

Name Description
PropertyChanged

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

확장명 메서드

Name Description
Focus(ModelItem, Int32)

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

Focus(ModelItem)

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

GetEditingContext(ModelItem)

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

GetModelPath(ModelItem)

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

IsParentOf(ModelItem, ModelItem)

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

적용 대상