3

I want to use MonoTouch.Dialog RadioElements for selecting data and it has to have a UIImageView for the TableView BackgroundViews.

I can set the BackgroundView on the initial DialogViewController's TableView so no problem there, but the TableView's generated for each RadioGroup has the default grey background image and I can't seem to find a way to change them to the same background style as the initial TableView.

Is it possible to change the generated TableView's BackgroundView (the TableView's generated for each RadioGroup) without having to go and modify the MonoTouch.Dialog source?

Thanks in advance.

poupou
  • 43,413
  • 6
  • 77
  • 174
bertusaurus
  • 634
  • 1
  • 6
  • 12
  • 1
    Sorry I mis-read your original question. I was under the impression that `RadioGroup` was non-UI related, i.e. without a table (need to check that again). Could it be the RootElement's TableView ? If so the same inherit-and-override trick would do. – poupou Oct 26 '11 at 02:36
  • It is, which I discovered earlier. Thanks! – bertusaurus Oct 26 '11 at 03:22
  • So what was the final answer? – Dylan Jul 22 '12 at 22:55

2 Answers2

3

AFAIK you'll need to create your own Element. But the good news is that's pretty easy to do, e.g.:

public class TransparentRootElement : RootElement {

    // add required .ctors

    public override UITableViewCell GetCell (UITableView tv)
    {
        var cell = base.GetCell (tv);
        cell.BackgroundColor = UIColor.Clear;
        return cell;
    }
}

Then you only have to use this new TransparentRootElement type where you create the RadioGroup.

poupou
  • 43,413
  • 6
  • 77
  • 174
0
public class CustomRootElement : RootElement
{
    public CustomRootElement(string caption, RadioGroup group) : base(caption, group)
    {

    }
    protected override MonoTouch.UIKit.UIViewController MakeViewController()
    {
        DialogViewController result = (DialogViewController)base.MakeViewController();
        // set the background here
        result.TableView.BackgroundColor = UIColor.ScrollViewTexturedBackgroundColor;

        return result;
    }

}
Dylan
  • 1,919
  • 3
  • 27
  • 51