2012-01-21 3 views
0

삼각형, 타원 등을 계승 한 클래스 모양이 있습니다. 질문. 보기에서 그림을 어떻게 바꿀 수 있습니까? 내가 공분산 및 MVVM

public class MainViewModel : NotificationObject 
{ 
    private Shape shape; 

    public MainViewModel() 
    { 
     Shape = new Ellipse; 
     ChangeCurrentShapeCommand = new DelegateCommand(ChangeCurrentShape); 
    } 

    public Shape Shape 
    { 
     get 
     { 
      return this.shape; 
     } 
     set 
     { 
      this.shape = value; 
      this.RaisePropertyChanged(() => this.Shape); 
     } 
    } 

    public DelegateCommand ChangeCurrentShapeCommand { get; set; } 

    private void ChangeCurrentShape() 
    { 
     Shape = new Triangle; 
    } 
} 

뷰 모델

에 수치를 변경하면 나는 타원이 삼각형으로 변경 화면에 ChangeCurrentShapeCommand를 호출 할 때.

답변

2

보기

2) 각각의 형상 종류 (삼각형, 타원 Data Templates 정의 Shape-1) 귀속 등)