コード例 #1
0
        public NonMobileUserPopupPageViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, IWindowsManager windowsManager, ILocationManager locationManager) : base(regionManager)
        {
            _eventAggregator = eventAggregator;
            _windowsManager  = windowsManager;
            _locationManager = locationManager;

            this.CancelCommand = new DelegateCommand(() => ExecuteCancelCommand());

            this.FillCommand = new DelegateCommand(async() => await ExecuteFillCommand());

            this.CountriesSelectionChangedCommand = new DelegateCommand(() => ExecuteCountriesSelectionChangedCommand());
            this.StatesSelectionChangedCommand    = new DelegateCommand(() => ExecuteStatesSelectionChangedCommand());

            if (this.Countries == null)
            {
                this.Countries       = _locationManager.GetCountries();
                this.SelectedCountry = this.Countries.FirstOrDefault();

                PostalCodePlaceholder = this.SelectedCountry.Id == 231 ? "Zip Code" : "Postal Code";
            }

            if (this.States == null && this.SelectedCountry != null)
            {
                var states = _locationManager.GetStates();
                this.States        = states.Where(x => x.CountryId == this.SelectedCountry.Id).ToList();
                this.SelectedState = this.States.FirstOrDefault();
            }

            if (this.Cities == null && this.SelectedState != null)
            {
                var cities = _locationManager.GetCities();
                this.Cities       = cities.Where(x => x.StateId == this.SelectedState.Id).ToList();
                this.SelectedCity = this.Cities.FirstOrDefault();
            }
        }