This question is locked. New answers and comments are not allowed.
Hello,
I am using VirtualQueryableCollectionView to implement Data Virtualization. Upon receiving data in completed event of a service call i am calling the Load method of the view. However it doesn't populate the view with received items and the grid remains empty. Here is the piece of code which tries to load items into view.
Here is the implementation of DynamicRow class which might help.
Please can you guide what may be missing to successfully load items into view. Thanks.
Regards,
Omer Javed
I am using VirtualQueryableCollectionView to implement Data Virtualization. Upon receiving data in completed event of a service call i am calling the Load method of the view. However it doesn't populate the view with received items and the grid remains empty. Here is the piece of code which tries to load items into view.
public void OnLookupCompleted(object sender, LookupRecordsCompletedEventArgs e) {...DynamicItems.Load(0, PrepareDynamicRows(e.Response.LookupRows)); ...}public ObservableCollection<dynamic> PrepareDynamicRows(List<LookupRow> lookupRows) { ObservableCollection<dynamic> dynamicRows = new ObservableCollection<dynamic>(); lookupRows.ForEach(x => dynamicRows.Add(new DynamicRow(x))); return dynamicRows; }Here is the implementation of DynamicRow class which might help.
public class DynamicRow : DynamicObject, INotifyPropertyChanged { LookupRow _lookupRow; public DynamicRow() { _lookupRow = new LookupRow(); } public DynamicRow(LookupRow lookupRow) { _lookupRow = lookupRow; } public override IEnumerable<string> GetDynamicMemberNames() { // output the avaiable names based on the dictionary of colum data, plus the Id field List<string> names = new List<string>(); names.Add("Id"); names.AddRange(_lookupRow.ColumnData.Keys); return names; } public override bool TryGetMember(GetMemberBinder binder, out object result) { result = this[binder.Name]; return true; } public override bool TrySetMember(SetMemberBinder binder, object value) { this[binder.Name] = value; return true; } /// <summary> /// Provides an indexer to retrieve either the Id or a value from the dictionary /// </summary> /// <param name="columnName"></param> /// <returns></returns> public object this[string columnName] { get { if (columnName == "Id") { return _lookupRow.RelatedEntity.Id; } if (_lookupRow.ColumnData.ContainsKey(columnName)) { return _lookupRow.ColumnData[columnName]; } return null; } set { if (columnName == "Id") { _lookupRow.RelatedEntity.Id = value as string; return; } if (!_lookupRow.ColumnData.ContainsKey(columnName)) { _lookupRow.ColumnData.Add(columnName, value); OnPropertyChanged(columnName); } else { if (_lookupRow.ColumnData[columnName] != value) { _lookupRow.ColumnData[columnName] = value; OnPropertyChanged(columnName); } } } } public LookupRow LookupRow { get { return _lookupRow; } set { _lookupRow = value; } } private void OnPropertyChanged(string propertyName) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } #region INotifyPropertyChanged Members public event PropertyChangedEventHandler PropertyChanged; #endregion }Please can you guide what may be missing to successfully load items into view. Thanks.
Regards,
Omer Javed