您的位置:首页 > 其它

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

2016-11-14 17:44 405 查看
功能:其他下拉框会随着第一个变动而变动

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; }

    }



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  WPF devexpress