当前位置: 首页>>代码示例>>C#>>正文


C# UITableView.SetCellStyle方法代码示例

本文整理汇总了C#中UITableView.SetCellStyle方法的典型用法代码示例。如果您正苦于以下问题:C# UITableView.SetCellStyle方法的具体用法?C# UITableView.SetCellStyle怎么用?C# UITableView.SetCellStyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UITableView的用法示例。


在下文中一共展示了UITableView.SetCellStyle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            View.BackgroundColor = UIColor.White;

            using (var set = new BindingSet<UserWorkspaceViewModel>())
            {
                var textField = new UITextField(new CGRect(20, 70, View.Frame.Width - 40, 30))
                {
                    AutoresizingMask = UIViewAutoresizing.FlexibleWidth,
                    Placeholder = "Name",
                    BorderStyle = UITextBorderStyle.RoundedRect
                };
                set.Bind(textField)
                    .To(() => (vm, ctx) => vm.UserEditorViewModel.Name)
                    .TwoWay()
                    .ValidatesOnExceptions()
                    .ValidatesOnNotifyDataErrors();
                View.AddSubview(textField);

                var label = new UILabel(new CGRect(6, 0, 60, 20))
                {
                    Text = "Validating...",
                    AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin,
                    AdjustsFontSizeToFitWidth = true,
                    TextColor = UIColor.Green
                };

                textField = new UITextField(new CGRect(20, 110, View.Frame.Width - 40, 30))
                {
                    AutoresizingMask = UIViewAutoresizing.FlexibleWidth,
                    Placeholder = "Login",
                    BorderStyle = UITextBorderStyle.RoundedRect
                };
                set.Bind(textField)
                    .To(() => (vm, ctx) => vm.UserEditorViewModel.Login)
                    .TwoWay()
                    .WithDelay(400)
                    .ValidatesOnExceptions()
                    .ValidatesOnNotifyDataErrors();
                set.Bind(textField, () => v => v.LeftViewMode)
                    .To(() => (vm, ctx) => vm.UserEditorViewModel.IsLoginValidating ? UITextFieldViewMode.Always : UITextFieldViewMode.Never);
                textField.LeftView = label;
                View.AddSubview(textField);

                textField = new UITextField(new CGRect(20, 150, View.Frame.Width - 40, 30))
                {
                    AutoresizingMask = UIViewAutoresizing.FlexibleWidth,
                    Placeholder = "Email",
                    BorderStyle = UITextBorderStyle.RoundedRect
                };
                set.Bind(textField)
                    .To(() => (vm, ctx) => vm.UserEditorViewModel.Email)
                    .TwoWay()
                    .ValidatesOnExceptions()
                    .ValidatesOnNotifyDataErrors();
                View.AddSubview(textField);

                var button = UIButton.FromType(UIButtonType.RoundedRect);
                button.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
                button.Frame = new CGRect(20, 190, View.Frame.Width / 2 - 20, 30);
                button.SetTitle("Add", UIControlState.Normal);
                set.Bind(button).To(() => (vm, ctx) => vm.AddUserCommand);
                View.AddSubview(button);

                button = UIButton.FromType(UIButtonType.RoundedRect);
                button.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
                button.Frame = new CGRect(View.Frame.Width / 2 - 20, 190, View.Frame.Width / 2 - 20, 30);
                button.SetTitle("Remove", UIControlState.Normal);
                set.Bind(button).To(() => (vm, ctx) => vm.RemoveUserCommand);
                View.AddSubview(button);


                var tableView = new UITableView(new CGRect(20, 230, View.Frame.Width - 40, View.Frame.Height - 230))
                {
                    AutoresizingMask = UIViewAutoresizing.FlexibleDimensions,
                };
                tableView.SetCellStyle(UITableViewCellStyle.Default);
                tableView.SetCellBind(cell =>
                {
                    cell.TextLabel.AdjustsFontSizeToFitWidth = true;
                    cell.TextLabel.Bind()
                        .To<UserModel>(() => (m, ctx) => string.Format("Name: {0} Login: {1} Email: {2}", m.Name, m.Login, m.Email))
                        .Build();
                });
                set.Bind(tableView, AttachedMemberConstants.ItemsSource)
                    .To(() => (vm, ctx) => vm.UserGridViewModel.ItemsSource);
                set.Bind(tableView, AttachedMemberConstants.SelectedItem)
                    .To(() => (vm, ctx) => vm.UserGridViewModel.SelectedItem)
                    .TwoWay();
                View.AddSubview(tableView);
            }
        }
开发者ID:dbeattie71,项目名称:MugenMvvmToolkit.Samples,代码行数:94,代码来源:UserWorkspaceViewController.cs


注:本文中的UITableView.SetCellStyle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。