如何获得并排带有2个按钮的元素? [英] How can I get an element with 2 buttons side by side?
本文介绍了如何获得并排带有2个按钮的元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要使用MvvmCross并排带有2个按钮的Monotouch.Dialog元素
I need to have a Monotouch.Dialog element with 2 buttons side by side using MvvmCross
有人管理过吗?
到目前为止,我已经知道了,但是由于无法知道点击了哪个按钮,因此无法正常工作.
I have this so far but know it's not going to work as I have no way of knowing which button was tapped:
public class DoubleButton : Element, IElementSizing{
UIImage image1;
UIImage image2;
public DoubleButton (UIImage image1,UIImage image2, string caption): base(caption)
{
this.image1 = image1;
this.image2 = image2;
}
protected override UITableViewCell GetCellImpl (UITableView tv)
{
var cell = base.GetCellImpl (tv);
cell.BackgroundColor = UIColor.Clear;
cell.SelectionStyle = UITableViewCellSelectionStyle.None;
var imageView1 = new UIImageView (image1);
var imageView2 = new UIImageView (image2);
cell.ContentView.Add (imageView1);
cell.ContentView.Add (imageView2);
return cell;
}
public float GetHeight (UITableView tableView, NSIndexPath indexPath)
{
return 80;
}
}
推荐答案
如果需要两个按钮和两个命令,则只需添加两个按钮和两个命令-然后使按钮触发命令即可.
If you want two buttons and two commands, then you can just add two buttons and two commands - then make the button's trigger the commands.
public class DoubleButton : Element, IElementSizing
{
UIButton button1;
UIButton button2;
public ICommand Command1 { get;set; }
public ICommand Command2 { get;set; }
public DoubleButton (UIButton b1,UIButton b2, string caption): base(caption)
{
this.button1 = button1;
this.button2 = button2;
this.button1.TouchUpInside += (s,e) => { if (Command1 != null) Command1.Execute(null); };
this.button2.TouchUpInside += (s,e) => { if (Command2 != null) Command2.Execute(null); };
}
// ....
这篇关于如何获得并排带有2个按钮的元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文