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; }
}
![](https://img-blog.csdn.net/20161114181335131?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
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; }
}
相关文章推荐
- DevExpress:grid中绑定下拉框ComboBoxEdit,只带显示
- DevExpress:下拉框绑定数据源 (ComboBoxEdit,LookUpEdit)
- C# 程序中如何向(DEV)ComboBoxEdit控件中添加下拉列表的值不使用数据绑定,就是使用代码添加
- DevExPress控件中ComboBoxEdit动态绑定数据
- [DevExpress]设置RepositoryItemComboBox只可下拉选择不可编辑
- DevExpress:下拉框绑定数据源 (ComboBoxEdit,LookUpEdit)
- DevExpress 中 用 LookUpEdit 控件 代替 ComboBoxEdit 控件来绑定 DataTable
- Devexpress 使用comboBoxEdit 和LookUpEditor 控件数据绑定
- WPF DevExpress ComboBoxEdit 实现键值绑定,输入字符自动匹配
- DevExpress.XtraEditors.ComboBoxEdit 只能选择不能在里面 输入数据
- checkedcomboboxedit控件的值的绑定 并选择指定项
- MFC 控件下拉选择和输入的 ComboBox使用
- 强大DevExpress,Winform LookUpEdit 实现多列查询 gridview弹出下拉选择
- 基于javascript实现全国省市二级联动下拉选择菜单
- TextBox下拉绑定TreeView进行选择
- DevExpress Grid中ComboBoxEdit的使用
- 第三方控件DevExpress的TreeList绑定XML文件
- DevExpress 利用DateEdit 仅显示和选择年份 z
- C#实现下拉框绑定list集合的方法