我正在创建一个像这样的列表框(devexpress control)
<dxe:ListBoxEdit x:Name="lstBoxFeatures" DisplayMember="Description" ValueMember="FeatureId" SelectionMode="Multiple"
ItemsSource="{Binding Path=DataContext.Features, RelativeSource={RelativeSource AncestorType=Window}}" Height="320"
EditValue="{Binding Path=DataContext.SelectedFeatures, RelativeSource={RelativeSource AncestorType=Window}}"
>
<dxe:ListBoxEdit.StyleSettings>
<dxe:CheckedListBoxEditStyleSettings />
</dxe:ListBoxEdit.StyleSettings>
</dxe:ListBoxEdit>
我有观点,我这样填写 我填写这样的值(使用功能列表)
_CustomerLicense.Features = GetFeatureList(SelectedLicense.Product.ProductId);
_CustomerLicense.SelectedFeatures =_CustomerLicense.Features.Where(x => FeaturesIds.Contains(x.FeatureId)).ToList();
我获得功能列表的过程
private List<Feature> GetFeatureList(Project.Common.Domain.ProductEnum ProductID )
{
var Res = new List<Feature>();
var Features = new LicenseService().GetFeatures(ProductID);
Features.ForEach((x)=> {
Res.Add(new Feature(x));
});
return Res;
}
我有这样的观点
public List<Feature> Features
{
get { return _Features;}
set
{
_Features = value;
this.NotifyPropertyChanged("Features");
}
}
public List<Feature> SelectedFeatures
{
get { return _SelectedFeatures; }
set
{
_SelectedFeatures = value;
NotifyPropertyChanged("SelectedFeatures");
}
}
当我运行应用程序时,它会设置值,列表框中会填充列表中的所有配置,但不会选中所选的功能。 此致
答案 0 :(得分:1)
尝试将for i,rowData in df.iterrows():
i = i-1
j = i/2
df['NewCol'].iloc[i] = abc[j]
声明为对象列表(您还需要更改SelectedFeatures
):
_SelectedFeatures
并更改此行:
public List<object> SelectedFeatures
{
get { return _SelectedFeatures; }
set
{
_SelectedFeatures = value;
NotifyPropertyChanged("SelectedFeatures");
}
}
答案 1 :(得分:0)
SelectedFeatures
集合应包含Feature
集合中Features
个实例的子集。试试这个:
var features = GetFeatureList(SelectedLicense.Product.ProductId);
_CustomerLicense.Features = features;
var selectedFeatureIds = _CustomerLicense.Features.Where(x => FeaturesIds.Contains(x.FeatureId)).Select(x => x.FeatureId).ToList();
_CustomerLicense.SelectedFeatures = features.Where(x => selectedFeatureIds.Contains(x.FeatureId)).ToList();