public void AddPropertyFields(string headerText = null) { if (DataObject == null) return; ContentItems.Clear(); var ps = DataObject.GetPropertiesWithAttribute<InspectorProperty>().ToArray(); if (ps.Length < 1) return; if (!string.IsNullOrEmpty(headerText)) ContentItems.Add(new SectionHeaderViewModel() { Name = headerText, }); var data = DataObject; foreach (var property in ps) { PropertyInfo property1 = property.Key; var vm = new PropertyFieldViewModel() { Type = property.Key.PropertyType, Name = property.Key.Name, InspectorType = property.Value.InspectorType, CustomDrawerType = property.Value.CustomDrawerType, Getter = () => property1.GetValue(data, null), DataObject = data, Setter = (d,v) => { property1.SetValue(d, v, null); } }; ContentItems.Add(vm); } IsDirty = true; }
private async Task ExecuteLoadDocumentsCommand() { if (IsBusy) { return; } IsBusy = true; try { ContentItems.Clear(); var contentItems = await DataStore.GetContentItemsAsync(true); ContentItems.ReplaceRange(contentItems); } catch (Exception ex) { Debug.WriteLine(ex); MessagingCenter.Send(new MessagingCenterAlert { Title = "Error", Message = "Unable to load content items.", Cancel = "OK" }, "message"); } finally { IsBusy = false; } }
/// <summary> /// Clear the collection /// </summary> public void Clear() { if (ContentItems != null && FilteredItems != null) { ContentItems.Clear(); FilteredItems.Clear(); } }
/// <summary> /// Remove all content from the collection /// </summary> public void Clear() { if (Loaded) { throw new InvalidOperationException("Cannot clear content while the ContentCollection is loaded"); } ContentItems.Clear(); }
protected override void CreateContent() { ContentItems.Clear(); }