예제 #1
0
        public MainWindow()
        {
            InitializeComponent();

            Customer obj = new Customer();
            obj.CustomerName = "Maria";
            obj.Amount = 2000;
            obj.Married = "Married";

            lblCustomerName.Content = obj.CustomerName; // mapping code
            lblSalesAmount.Content = obj.Amount; // mapping code

            if (obj.Amount > 2000) // transformation code
            {
                lblHabits.Background = new SolidColorBrush(Colors.Blue);
            }
            else if (obj.Amount > 1500) // transformation code
            {
                lblHabits.Background = new SolidColorBrush(Colors.Red);
            }
            if (obj.Married == "Married") // transformation code
            {
                chkMarried.IsChecked = true;
            }
            else
            {
                chkMarried.IsChecked = false;
            }
        }
        public MainViewModel()
        {
            InitializeComponent();

            Customer obj = new Customer();
            obj.CustomerName = "Maria";
            obj.Amount = 2000;
            obj.Married = "Married";

            CustomerViewModel viewModel = new CustomerViewModel(obj);

            DisplayUi(viewModel);
        }
 public CustomerViewModel(Customer customer)
 {
     obj = customer;
 }