DevExpress ComboBoxEdit List绑定二级选择下拉表

来源:互联网 发布:知乎恐怖提问 编辑:程序博客网 时间:2024/06/08 05:07

功能:其他下拉框会随着第一个变动而变动

Xaml

             xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
             xmlns:dxlc="http://schemas.devexpress.com/winfx/2008/xaml/layoutcontrol"

<dxlc:LayoutGroup >

                            <dxlc:LayoutItem Width="150" Label="设备类型">
                                <dxe:ComboBoxEdit Name="deviceTypeList" EditValue="{Binding DeviceTypes,UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding DeviceTypeList}" DisplayMember="DeviceType"  ValueMember="DeviceType" IsTextEditable="False"  >
                            </dxe:ComboBoxEdit>
                            </dxlc:LayoutItem>

                            <dxlc:LayoutItem Width="250" Label="设备名称">
                                <dxe:ComboBoxEdit Background="{x:Null}" IsEnabled="True" ItemsSource="{Binding ElementName=deviceTypeList,Path=SelectedItem.DeviceNames}"   EditValue="{Binding SelectedNameList, Mode=TwoWay}" >
                                    <dxe:ComboBoxEdit.StyleSettings>
                                        <dxe:CheckedComboBoxStyleSettings />
                                    </dxe:ComboBoxEdit.StyleSettings>
                                </dxe:ComboBoxEdit>
                            </dxlc:LayoutItem>

                            <dxlc:LayoutItem Width="250" Label="设备属性">
                                <dxe:ComboBoxEdit IsEnabled="True" ItemsSource="{Binding ElementName=deviceTypeList,Path=SelectedItem.TagNames}"   EditValue="{Binding SelectedTypeList, Mode=TwoWay}" >
                                    <dxe:ComboBoxEdit.StyleSettings>
                                        <dxe:CheckedComboBoxStyleSettings />
                                    </dxe:ComboBoxEdit.StyleSettings>
                                </dxe:ComboBoxEdit>
                            </dxlc:LayoutItem>

 </dxlc:LayoutGroup>

DisplayMember="DeviceType"  是显示GetDataStoreDeviceTypeRet对象中DeviceType属性的值

ValueMember="DeviceType" 是绑定GetDataStoreDeviceTypeRet对象中DeviceType属性的值

ElementName=deviceTypeList,Path=SelectedItem.DeviceNames  ElementName绑定name为deviceTypeList的控件,Path是绑定了name为deviceTypeList的控件选择的具体对象的DeviceNames  属性

.cs

//设备类型绑定的 ItemsSource

public List<GetDataStoreDeviceTypeRet> DeviceTypeList
        {
            get
            {
                return _deviceTypeList;
            }
            set
            {
                _deviceTypeList = value;
                OnPropertyChanged();
            }
        }

//对象

public class GetDataStoreDeviceTypeRet
    {
       
        public string DeviceType { get; set; }
      
        public List<string> DeviceNames { get; set; }

      
        public List<string> TagNames { get; set; }
    }


0 0
原创粉丝点击