【发布时间】:2014-09-02 10:57:24
【问题描述】:
我需要能够将网格绑定到变量类型的集合(接口/类型 T/动态等)
我认为我可以将集合绑定到一个接口,然后更改从该接口扩展的对象,并且 UI 会相应地更新。
private readonly ObservableCollection<IExportItemModel> _exportedDataCollection = new ObservableCollection<IExportItemModel>();
public ObservableCollection<IExportItemModel> ExportedDataCollection
{
get
{
return _exportedDataCollection;
}
}
.
List<spGetDataByTransactionId_Result> t = _repository.GetDataByTransactionId(new Guid());
List<IExportItemModel> tempList = new List<IExportItemModel>();
t.ForEach(r=>tempList.Add(new FixedWidthModel(r)));
ExportedDataCollection.AddRange(tempList);
但是 UI 没有反映这些变化,或者至少 DevExpress 没有。
有没有更好的方法我没有想到?
提前致谢, 奥利
【问题讨论】:
-
你的意思是 UP 没有反映这些变化?你希望看到什么?你在看什么?
-
是收藏不更新吗?还是您的模型内容?如果不知道 IExportItemModel 是什么就很难说,你能把它贴出来吗?请记住,如果绑定到列表中的项目,您需要让 IExportItemModel 继承 INotifyPropertyChanged,以便向 gui 发出需要重绘的信号。给我们更多信息,我相信我们可以为您提供帮助 =)
-
@Stian IExportItemModel 是一个空接口,它什么都没有。我做它纯粹是为了有一个接口到范围和一个类型来绑定集合。
-
@Noctis UI 什么都不做,甚至不显示类型,但我认为 DevExpress 正在掩盖这一点。
-
@Oli 我无法回答你的问题,没有更多信息,比如你的 xaml。所以我明白你想在这里做什么。你的 debugoutbut 说什么?任何绑定错误异常等?
标签: wpf dynamic binding devexpress observablecollection