Пример #1
0
        private void cmbCity_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (!this.needChange)
            {
                return;
            }
            if (cmbCity.SelectedIndex > 0)
            {
                int citySysNumber = System.Convert.ToInt32(cmbCity.SelectedValue);
                this.SelectedCitySysNo = citySysNumber.ToString();

                Facade.QueryCurrentAreaStructure(citySysNumber, (obj, args) =>
                {
                    if (args.FaultsHandle())
                    {
                        return;
                    }
                    this.needChange = false;
                    ViewModel       = AreaQueryTransform.Transform(args.Result);
                    //cmbArea.ItemsSource = ViewModel.DistrictAreaList;
                    this.SelectedCityName = ViewModel.CityeAreaList.Where(f => f.Key == citySysNumber.ToString()).FirstOrDefault().Value;
                    // this.SelectedCityName = ViewModel.CityeAreaList;
                    this.needChange = true;
                    //ClearValidationError(cmbArea);
                });
            }
            else
            {
                this.needChange = false;
                //cmbArea.ItemsSource = SingleSource;
                //cmbArea.SelectedIndex = 0;
                this.SelectedAreaSysNo = null;
                this.needChange        = true;
            }
        }
Пример #2
0
        private void BindData()
        {
            string query = string.IsNullOrEmpty(this.SelectedAreaSysNo) ? "-999" : this.SelectedAreaSysNo;

            Facade.QueryCurrentAreaStructure(System.Convert.ToInt32(query), (obj, args) =>
            {
                if (args.FaultsHandle())
                {
                    return;
                }
                ViewModel = AreaQueryTransform.Transform(args.Result);

                string areaSysNo = null;
                if (!string.IsNullOrEmpty(this.SelectedAreaSysNo))
                {
                    areaSysNo = this.SelectedAreaSysNo;
                }

                this.needChange = false;

                cmbProvince.ItemsSource = ViewModel.ProvinceAreaList;
                cmbCity.ItemsSource     = ViewModel.CityeAreaList;
                //在给ComboBox的数据源赋值后,会触发SelectionChanged时间,导致SelectedAreaSysNo为null,所以需要把SelectedAreaSysNo先存起来
                //cmbArea.ItemsSource = ViewModel.DistrictAreaList;

                this.needChange = true;

                if (!string.IsNullOrEmpty(areaSysNo))
                {
                    this.SelectedAreaSysNo = areaSysNo;
                }

                if (string.IsNullOrEmpty(this.SelectedAreaSysNo))
                {
                    cmbProvince.SelectedIndex = 0;
                }
                else
                {
                    this.needChange = false;


                    cmbProvince.SelectedValue = ViewModel.CurrentArea.ProvinceSysNumber;
                    cmbCity.SelectedValue     = ViewModel.CurrentArea.CitySysNumber;

                    //cmbArea.SelectedValue = ViewModel.CurrentArea.SysNumber;

                    this.needChange = true;
                }
            });
        }