WPF的下拉复选框多选,数据泉源数据库的表

打印 上一主题 下一主题

主题 1621|帖子 1621|积分 4863

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

x
页面控件利用                 
  <Label Style="{StaticResource ListSearch-Label}" Content="走货方式:"/>
                    <c1:C1ComboBox BorderThickness="1" Width="110"
                    <xctk:CheckComboBox Width="113" Style="{StaticResource ListSearch-XctkCheckComboBox}" 
                                        ItemsSource="{Binding ShippmentWayList,Mode=TwoWay}" 
                                        DisplayMemberPath="ShipWay" ValueMemberPath="ShipWay" 
                                        SelectedItemsOverride="{Binding ShippmentWayItems,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, 
                                        ValidatesOnExceptions=True, ValidatesOnDataErrors=True, NotifyOnValidationError=True}"
                                        SelectedValue="{Binding ShippmentWay, Mode=TwoWay}"/>

cs

  private ObservableCollection<dynamic> _shippmentWayItems;

        private string _shippmentWay;
        public string ShippmentWay
        {
            get
            {
                return _shippmentWay;
            }
            set
            {
                if (_shippmentWay != null && _shippmentWay.Contains("-1") && value != null && !value.Contains("-1"))
                {
                    _shippmentWayItems = new ObservableCollection<dynamic>() { };
                }
                  //等于-1这个可以护理,我的key和value用的都是中文
                else if (_shippmentWay != null && !_shippmentWay.Contains("-1") && value != null && value.Contains("-1"))
                {
                    _shippmentWay = InitWayStatus();
                    _shippmentWayItems = new ObservableCollection<dynamic>() { };
                    foreach (var item in ShippmentWayList)
                    {
                        _shippmentWayItems.Add(new { name = item.ShipWay, value = item.ShipWay });
                    }
                }
                _shippmentWay = value;
                if (SearchItem != null)
                {
                    SearchItem.ShippmentWay = _shippmentWay;
                }
                RaisePropertyChanged(() => ShippmentWayItems);
                RaisePropertyChanged(() => ShippmentWay);
            }
        }

        /// <summary>
        /// 获取全部走货方式数据泉源数据库
        /// </summary>
        private void GetShipingWayList() 
        {
            string error;
            var list = _shipWayService.FindByIsShip((int)_fSaleType, out error);
            if (list == null)
            {
                ShippmentWayList = new ObservableCollection<ShipWayModel>();
            }
            else
            {
                ShippmentWayList = new ObservableCollection<ShipWayModel>(list);
            }
            RaisePropertyChanged(() => ShippmentWayList);
        }
 /// <summary>
        /// 默认走货方式的状态初始化,把这个方法放在初始化种
        /// </summary>
        /// <returns></returns>
        private string InitWayStatus()
        {
            var list = new List<string>();
            if (ShippmentWayList==null) {
                GetShipingWayList();
            }
            foreach (var item in ShippmentWayList)
            {
                list.Add(item.ShipWay);
            }
            return string.Join(",", list);
        }
 

 

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

小秦哥

论坛元老
这个人很懒什么都没写!
快速回复 返回顶部 返回列表