protected override UITableViewCell NewCell(NSString cellId, NSIndexPath indexPath) { var id = cellId; var memberData = GetMemberData(indexPath); if (memberData != null) { id = memberData.Id; } var section = Sections[indexPath.Section]; var listSource = GetListSource(indexPath); if ((typeof(IEnumerable).IsAssignableFrom(memberData.Type) || typeof(Enum).IsAssignableFrom(memberData.Type)) && listSource != null && !listSource.IsRootCell) { id = listSource.CellId; } if (memberData != null) { var viewType = ViewContainer.GetView(memberData); if (viewType != null) { var key = id.ToString(); if (section.ViewTypes.ContainsKey(key)) { var viewTypeList = section.ViewTypes[key]; if (viewTypeList == null) { viewTypeList = new List <Type>(); section.ViewTypes[key] = viewTypeList; if (!viewTypeList.Contains(viewType)) { viewTypeList.Add(viewType); } } } else { section.ViewTypes.Add(key, new List <Type>() { viewType }); } } } return(base.NewCell(id, indexPath)); }
public void NavigateToView() { var viewType = NavigationViewType; if (viewType == null) { viewType = ViewContainer.GetView(SelectedItem.GetType()); } if (viewType != null) { var disposable = NavigationView as IDisposable; if (disposable != null) { disposable.Dispose(); } NavigationView = Activator.CreateInstance(viewType); var dc = NavigationView as IDataContext <object>; if (dc != null) { dc.DataContext = SelectedItem; } else { NavigationView = SelectedItem; } var initializable = NavigationView as IInitializable; if (initializable != null) { initializable.Initialize(); } Caption = SelectedItem.ToString(); var dvc = new DialogViewController(Caption, NavigationView, Controller.Theme, true); Controller.NavigationController.PushViewController(dvc, true); } }
public void NavigateToList() { var section = Sections[0]; var data = GetSectionData(0); if (string.IsNullOrEmpty(Caption)) { Caption = data.ToString(); } var dvc = new DialogViewController(Caption, null, Controller.Theme, true) { ToolbarButtons = null, NavbarButtons = null }; if (NavigationSource == null) { NavigationSource = new ListSource(dvc, data, section.ViewTypes[CellId]); } NavigationSource.SelectionAction = SelectionAction; NavigationSource.IsSelectable = (SelectionAction == SelectionAction.PopOnSelection || SelectionAction == SelectionAction.Selection || SelectionAction == SelectionAction.Multiselection); NavigationSource.NavigationViewType = null; var viewType = NavigationViewType; if (viewType == null && SelectionAction == SelectionAction.NavigateToView) { var genericType = data.GetType().GetGenericArguments().FirstOrDefault(); viewType = ViewContainer.GetView(genericType); } if (viewType != null) { NavigationSource.IsNavigable = viewType == typeof(ObjectCellView <object>); NavigationSource.NavigationViewType = viewType; } NavigationSource.IsNavigable = !PopOnSelection && NavigationSource.IsNavigable && SelectionAction != SelectionAction.Custom; NavigationSource.CellFactory = CellFactory; NavigationSource.SelectedItem = SelectedItem; NavigationSource.SelectedItems = SelectedItems; NavigationSource.UnselectionBehavior = UnselectionBehavior; NavigationSource.IsMultiselect = IsMultiselect; // NavigationSource.IsSelectable = IsSelectable; if (data.Count > 0 && (data[0].GetType().IsPrimitive || data[0].GetType().IsEnum)) { NavigationSource.IsSelectable = true; } NavigationSource.PopOnSelection = PopOnSelection; NavigationSource.NibName = NibName; NavigationSource.TableViewStyle = TableViewStyle; NavigationSource.IsSearchbarHidden = IsSearchbarHidden; NavigationSource.EnableSearch = EnableSearch; NavigationSource.IncrementalSearch = IncrementalSearch; NavigationSource.SearchPlaceholder = SearchPlaceholder; NavigationSource.SearchCommand = SearchCommand; NavigationSource.SelectedAccessoryViewType = SelectedAccessoryViewType; NavigationSource.UnselectedAccessoryViewType = UnselectedAccessoryViewType; NavigationSource.MemberData = new MemberData(MemberData.Source, MemberData.Member); if (NavigationSource.NavigationViewType != null) { var rowHeightAttribute = NavigationSource.NavigationViewType.GetCustomAttribute <RowHeightAttribute>(); if (rowHeightAttribute != null) { NavigationSource.MemberData.RowHeight = rowHeightAttribute.RowHeight; } } NavigationSource.Controller = dvc; dvc.TableView.Source = NavigationSource; Controller.NavigationController.PushViewController(dvc, true); }