Skip to content

Instantly share code, notes, and snippets.

@wayne-o
Created December 17, 2013 10:29
Show Gist options
  • Save wayne-o/8002890 to your computer and use it in GitHub Desktop.
Save wayne-o/8002890 to your computer and use it in GitHub Desktop.
Side by side buttons
public class SafeClaimDoubleButton : Element, IElementSizing{
UIButton button1;
UIButton button2;
public ICommand Command1 { get;set; }
public ICommand Command2 { get;set; }
public SafeClaimDoubleButton (UIButton b1,UIButton b2, string caption): base(caption)
{
this.button1 = b1;
this.button2 = b2;
this.button1.TouchUpInside += (s,e) => { if (Command1 != null) Command1.Execute(null); };
this.button2.TouchUpInside += (s,e) => { if (Command2 != null) Command2.Execute(null); };
}
protected override UITableViewCell GetCellImpl (UITableView tv)
{
var cell = base.GetCellImpl (tv);
cell.BackgroundColor = UIColor.Clear;
cell.SelectionStyle = UITableViewCellSelectionStyle.None;
var combinedWidth = button1.Frame.Width + button2.Frame.Width;
var frame1 = button1.Frame;
var frame2 = button2.Frame;
var xCenter = UIScreen.MainScreen.Bounds.Width / 2;
var quarterScreenWidth = UIScreen.MainScreen.Bounds.Width / 4;
frame1.X = xCenter - quarterScreenWidth - button1.Frame.Width /2;
frame2.X = xCenter + quarterScreenWidth - button2.Frame.Width /2;
button1.Frame = frame1;
button2.Frame = frame2;
cell.ContentView.Add (button1);
cell.ContentView.Add (button2);
return cell;
}
public float GetHeight (UITableView tableView, NSIndexPath indexPath)
{
return 80;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment