コード例 #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //리스트 항목 추가
            MyListViewModel listViewModel = FindResource("MyListViewModel") as MyListViewModel;

            listViewModel.MyList.Add(new MyItem(TxtName));
        }
コード例 #2
0
        //리스트 뷰 모델 생성
        //MyListViewModel listViewModel = new MyListViewModel();

        public MainWindow()
        {
            InitializeComponent();

            //리스트 항목 추가
            MyListViewModel listViewModel = FindResource("MyListViewModel") as MyListViewModel;

            listViewModel.MyList.Add(new MyItem("송병호"));
            listViewModel.MyList.Add(new MyItem("김태균"));
            listViewModel.MyList.Add(new MyItem("김진영"));

            //리스트뷰 바인딩
            //lvList.DataContext = listViewModel;         //모델 바인딩
            //lvList.ItemsSource = listViewModel.MyList;  //아이템 소스 바인딩
        }