MvvmCross与自定义UITableViewDelegate的TableView绑定

时间:2014-09-08 06:40:27

标签: mvvmcross

我有一位代表:

public class MyTableDelegate: UITableViewDelegate
{
    int _row;
    public override void RowSelected (UITableView tableView, NSIndexPath indexPath)
    {
        _row = indexPath.Row;
        tableView.BeginUpdates ();
        tableView.EndUpdates ();
    }

    public override float GetHeightForRow (UITableView tableView, NSIndexPath indexPath)
    {
        if (indexPath.Row == _row)
            return 80;
        else
            return 60;
    }           
}

在我看来:

public override void ViewDidLoad ()
    {
        base.ViewDidLoad ();
        var source = new MvxSimpleTableViewSource(tblUsers, UserViewCell.Key, UserViewCell.Key);
        tblUsers.Source = source;
        var set = this.CreateBindingSet<UsersPopoverView, UsersPopoverViewModel>();
        tblUsers.Delegate = new MyTableDelegate ();
        set.Bind(source).To(vm => vm.Users);
        set.Bind(source).For(s => s.SelectionChangedCommand).To(vm => vm.SelectUserCommand);
        set.Bind(this).For(s => s.DismissMe).To(vm => vm.Dismiss);
        set.Apply();
    }

当我有tblUsers.Delegate = new MyTableDelegate();数据绑定不起作用。如何绑定我的TableView并使用我的自定义委托?

0 个答案:

没有答案