I am using MonoTouch.Dialog to create a page in my Xamarin iOS app.
I am trying to create a multi-line RootElement by leveraging the GetCell method. This works fine on load, but if you click to a different tab and back the element shrinks back to default size (also when you click the element you see it shrink before the transition).
I have tried messing with UnevenRows with no success so far.
public partial class TestController : UITabBarController
{
public TestController()
: base("TestController", null)
{
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
var navController = new UINavigationController
{
Title = "Test1"
};
navController.PushViewController(new TestDialogViewController(), false);
ViewControllers = new[]
{
navController,
new UIViewController
{
Title = "Test2"
},
};
}
}
public class TestDialogViewController : DialogViewController
{
public TestDialogViewController() : base(new RootElement("Test"))
{
Root.UnevenRows = true; // has no effect
var testSection = new Section("Test section");
var testChildRootElement = new CustomRootElement("Multi\nLine\nElement")
{
UnevenRows = true // has no effect
};
var testChildSection = new Section("Test child section");
var testEntryElement = new EntryElement(string.Empty, string.Empty, "Test entry element");
testChildSection.Add(testEntryElement);
testChildRootElement.Add(testChildSection);
testSection.Add(testChildRootElement);
Root.Add(testSection);
}
}
public class CustomRootElement : RootElement
{
public CustomRootElement(string caption) : base(caption) {}
public override UITableViewCell GetCell(UITableView tv)
{
var cell = base.GetCell(tv);
// Setup Multi-line Element
cell.TextLabel.LineBreakMode = UILineBreakMode.WordWrap;
cell.TextLabel.Lines = 0;
return cell;
}
}