MonoTouch.Dialog
MonoTouch.Dialog copied to clipboard
DialogViewController.Style does not cascade to nested offspring
Problem
When creating the topmost DialogViewController
, the UITableViewStyle
can be passed to the constructor, specifying a Plain
or Grouped
style. When RootElement.Selected
creates a nested table view, the style is not set, therefore the Style
that is initially set is ignored for all subsequently nested table views.
Solution 1 (simple)
Change Elements.cs:2807 RootElement.Selected
:
public override void Selected (DialogViewController dvc, UITableView tableView, NSIndexPath path)
{
tableView.DeselectRow (path, false);
var newDvc = MakeViewController ();
if(newDvc is DialogViewController)
(newDvc as DialogViewController).Style = dvc.Style;
PrepareDialogViewController (newDvc);
dvc.ActivateController (newDvc);
}
Solution 2 (flexible)
Add a TableViewStyle
property to RootElement
that is used by RootElement.Selected
when creating the nested table view.
Optionally add this as an argument in RootElement
's constructor.
This would allow the programmer to specify the style on a table-by-table basis.
There is already a mechanism for this, create your RootElement like this:
new RootElement ("Caption", (root) => return new DialogViewController(this,true) { Style = container.Style });
I agree it would have been a better idea to have the Style be there by default, but now that the API is in use by many apps, I do not want to change the behavior behind people's backs.