public PersonCollectionPlainViewModel(PersonDAL business)
        {
            System.Diagnostics.Debug.WriteLine("Constructing PersonCollectionPlainViewModel.");

            _business = business;
            if (PropStoreServicesForThisApp.InDesignMode())
            {
                PersonCollection = new ObservableCollection <Person>();
            }
            else
            {
                PersonCollection = new ObservableCollection <Person>(business.Get());
            }
        }
Exemplo n.º 2
0
        public DtoTestEmit()
        {
            if (PropStoreServicesForThisApp.InDesignMode())
            {
                System.Diagnostics.Debug.WriteLine("In Design");
                //OurData = new DtoTestViewModelEmit(PropBagTypeSafetyMode.Tight);
                //OurData.AddProp<int>("RunTimeInt", null, false, null, null, 17);
                //OurData.SetIt<int>(21, "RunTimeInt");
            }

            //OurData = new DtoTestViewModelEmit();
            InitializeComponent();

            // Create Proxy Classes dynamically for this View Model to enable AutoMapper mappings.
            //_autoMappers = GetAutoMappers(PropBagMappingStrategyEnum.EmitProxy);

            Grid topGrid = (Grid)this.FindName("TopGrid");

            //_boundPropBags = ViewModelGenerator.StandUpViewModels(topGrid, this);

            OurData.SetIt <MyModel4>(new MyModel4 {
                MyString = "hello"
            }, "Deep");

            //_autoMappers = PrepareAutoMappings(PropBagMappingStrategyEnum.EmitProxy);

            DefineMapingKeys("OurData");
            DefineMappers("OurData");

            // This is an example of how to create the binding whose source is a property in the Property Bag
            // to a UI Element in this class' view.
            // This same binding could have been created in XAML.

            //Binding c = new Binding("[System.Double, Size]")
            //{
            //    Converter = new PropValueConverter(),
            //    ConverterParameter = new TwoTypes(typeof(double), typeof(string)),
            //    TargetNullValue = string.Empty
            //};
            //TextBox tb = (TextBox)this.FindName("Sz");
            //tb.SetBinding(TextBox.TextProperty, c);
        }
        public MainWindowPlainViewModel()
        {
            if (PropStoreServicesForThisApp.InDesignMode())
            {
                _business = null;
            }
            else
            {
                IHaveADbContext dBActivator = new DBActivator <PersonDB>(System.Environment.SpecialFolder.CommonApplicationData);
                PersonDB        personDb    = (PersonDB)dBActivator.DbContext;
                _business = new PersonDAL(personDb);
            }

            PersonCollectionPlainViewModel = new PersonCollectionPlainViewModel(_business);

            personCollectionPlainViewModel.MessageHasArrived += delegate(object sender, MessageEventArgs args)
            {
                // Pass messages from the child view model to our listeners (i.e., our parent window.)
                ShowMessageBox(sender, args);
            };
        }