2018년 1월 29일 월요일

[Xamarin 예문] Creating a View Model Declaratively

 http://topcredu.co.kr/sub/crcl/view/c/2180  (자마린을 포함한 닷넷교육의 모든 것)



n  가장 간단한 접근법은 뷰가 XAML에서 해당 ViewModel을 선언적으로 인스컨스화 하는 것이다뷰가 구성되면 해당 ViewModel의 객체도 함께 생성된다.
n  아래 예문에서 ContentPage가 생성되면 EmpViewModel의 객체도 생성되고 뷰의 BindingContext로 EmpViewModel이 할당된다.
<ContentPage ... xmlns:local="clr-namespace:App6"> 
    <ContentPage.BindingContext> 
        <local:EmpViewModel /> 
    </ContentPage.BindingContext> 
    ... 
</ContentPage>

댓글 없음:

댓글 쓰기