0

I am trying to lightly customise by inheritance some Elements in Mvvmcross Dialog implementation.

Colors and fonts are getting set fine, but if I try to set the Text Labels frame (to 100 X ... in this example) I cannot get it to stick.

Can anyone point me in the direction of where I am going wrong here? tried it in a couple different places.

public class MyBooleanElement : BooleanElement {

    public MyBooleanElement (string caption) : base(caption, false)
    {

    }

    protected override UISwitch CreateSwitch()
    {
        UISwitch s = base.CreateSwitch();
        s.BackgroundColor = UIColor.Clear;
        s.Opaque = false;
        s.Layer.Opacity = 0.25f;
        return s;
    }

    protected override UITableViewCell GetCellImpl(UITableView tv)
    {
        var cell = base.GetCellImpl(tv);

        if (cell.BackgroundColor != UIColor.Clear) {
            cell.BackgroundColor = UIColor.Clear;
            cell.TextLabel.Font = Theme.GetContentFont();
            cell.TextLabel.TextColor = UIColor.White;

            cell.TextLabel.Frame =  new RectangleF(100, 0, 320, 20); // this is not holding, resets to 15
            cell.ContentView.Frame = new RectangleF(50, cell.ContentView.Frame.Top, cell.ContentView.Frame.Width, cell.ContentView.Frame.Height);  // try this also? 
        }

        return cell;
    }

    protected override void UpdateCaptionDisplay(UITableViewCell cell)
    {
        base.UpdateCaptionDisplay(cell);

        if (cell != null) {
            cell.TextLabel.Frame = new RectangleF(100, 0, 320, 20);  // this is not holding, resets to 15
            cell.TextLabel.BackgroundColor = UIColor.Blue;           // Yet this works? some constraints somewhere cannot see in source!
        }
    }
}
WickedW
  • 2,331
  • 4
  • 24
  • 54

1 Answers1

0

The dialog part of the framework is positioning the headers (labels) and controls for you.

You should look at the source code a bit, maybe try to understand how it works a little bit.

You can start with a breakpoint and step into the source code while debugging. I'm sure you are going to see where the 15 value is being set.

I'm sorry I can't give you an exact answer. I had some issues myself with the incorrect positioning of dialog elements on iPad, and I had to dig a bit.

WriteEatSleepRepeat
  • 3,083
  • 3
  • 33
  • 56
  • Thanks Andrei, I have had a good look at the source, and will have to set up Debugging as the next step as you say, as you can guess was hoping someone had hit this previously. Do you use Visual Studio on PC for debugging or XS? – WickedW Oct 27 '14 at 18:42