iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
I took the Master-Detail Wizard and I want to display custom view cells on that page. I need to expand the row to 152 pixels and I overrode the GetRowHeight on both the UITableViewController and it's delegate and it never hits that method to get the row height. What am I doing wrong?
[Register("MainViewController")] [ImportBinding(typeof(NavigationBindingProvider))] public class MainViewController : UITableViewController<NavigationViewModel> { #region Properties public override TableViewInteraction InteractionMode { get { return TableViewInteraction.Navigation; } } public override float GetHeightForRow (UITableView tableView, NSIndexPath indexPath) { return 152; } public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath) { return base.GetCell (tableView, indexPath); } public override bool ShowGroupHeader { get { return false; } } public override UITableViewStyle TableViewStyle { get { return UITableViewStyle.Grouped; } } public override TableViewCellStyle CellStyle { get { return TableViewCellStyle.Custom; } } public override UIViewTemplate CellTemplate { get { return new UIViewTemplate(BridgeTableViewCell.Nib); } } public override string CellIdentifier { get { return "BridgeTableViewCell"; } } #endregion #region Methods protected override void InitializeView() { base.InitializeView(); var label = new UILabel(); label.Text = "Powered by Crosslight®"; label.BackgroundColor = UIColor.Clear; label.TextColor = UIColor.DarkGray; label.ShadowColor = UIColor.White.ColorWithAlpha(0.8f); label.ShadowOffset = new SizeF(1, 1); label.Font = UIFont.SystemFontOfSize(14f); //label.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleRightMargin; label.SizeToFit(); label.Frame = new RectangleF(label.Frame.Left, label.Frame.Top, label.Frame.Width, label.Frame.Height + 8); label.Center = new PointF(this.View.Bounds.Width / 2, label.Bounds.Height / 2); // set TableView footer this.TableView.TableFooterView = label; // set navigation title this.NavigationItem.Title = "Crosslight App"; this.Appearance.BackgroundColor = UIColor.Clear; this.Appearance.BackgroundImage = "Bridge5.png"; this.TableView.Delegate = new MainTableDelegate (); } private class MainTableDelegate : UITableViewDelegate { public override float GetHeightForRow (UITableView tableView, NSIndexPath indexPath) { return 152; } } #endregion } }
Navigation View Model
public class NavigationViewModel : SampleListViewModelBase<BridgeNavigationItem> { private CameraRepository _repository; #region Properties public string AboutText { get { return _aboutText; } set { if (_aboutText != value) { _aboutText = value; OnPropertyChanged("AboutText"); } } } private string _aboutText { get; set; } #endregion #region Constructors public NavigationViewModel() { List<BridgeNavigationItem> items = new List<BridgeNavigationItem>(); _repository = new CameraRepository (); foreach (string item in _repository.GetAll()) { items.Add(new BridgeNavigationItem(item, "Piedras N...", typeof(CrossingOwlViewModel))); } //items.AddRange (_repository.GetAll ()); //items.Add (new NavigationItem ("Crossing Owls", "Cameras", typeof(CrossingOwlViewModel))); //items.Add(new NavigationItem("Simple Page", "About", typeof(SimpleViewModel))); //items.Add(new NavigationItem("About This App", "About", typeof(AboutNavigationViewModel))); this.SourceItems = items; this.RefreshGroupItems(); } #endregion #region Methods public override void RefreshGroupItems() { if (this.Items != null) this.GroupItems = this.Items.GroupBy(o => o.Group).Select(o => new GroupItem<NavigationItem>(o)).ToList(); } #endregion }
BridgeNavigationItem
public BridgeNavigationItem (string title, NavigationTarget target) : base(title, target) { } public BridgeNavigationItem(string title, string group, NavigationTarget target) : base(title, group, target) { } public BridgeNavigationItem(string title, string group, Type target) : base(title, group, target) { } public string BridgeName { get { return "Hello Bridge"; } } }
NavigationBindingProvider
public class NavigationBindingProvider : BindingProvider { #region Constructors public NavigationBindingProvider() { ItemBindingDescription itemBinding = new ItemBindingDescription() { DisplayMemberPath = "Title", NavigateMemberPath = "Target" }; this.AddBinding("TableView", BindableProperties.ItemsSourceProperty, "Items"); this.AddBinding("TableView", BindableProperties.ItemTemplateBindingProperty, itemBinding, true); this.AddBinding("TableView", BindableProperties.SelectedItemProperty, "SelectedItem", BindingMode.TwoWay); } #endregion }
Another noteworthy point is that if your custom table view cell has different height than the default, you should inherit the Crosslight’s default data source adapter and return the desired height in the GetHeight method of the adapter.
Source: Customizing Cell Styles on iOS section from Customizing Cell Styles documentation.
You may also check the CustomStyleListViewController.cs code on DataSamples sample project which implemennts custom height. Use a custom table source with customized row height in OnViewInitialized (line 48 on CustomStyleListViewController.cs code). And the delegate should derives from ObservableTableSource.
Hope this helps.
Dear Nicholas,
Please make sure you inherit your custom table source from ObservableTableSource as in the data sample. That's because the table source provided by Crosslight already include the required implementation that comply tothe ViewModel pattern.
If you still experience issues, please send over a sample and we're happy to assist you solving the issues.
Thanks!
File 1 of 3
Please find the modified version of DemoTableSource sample project in here.
The changes that were made to the original DemoTableSource sample project is as follow
double post
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname