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


C# UIBarButtonItem.SetCommand方法代码示例

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


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

示例1: ViewDidLoad

        public override void ViewDidLoad()
        {
            View = new UniversalView();
            base.ViewDidLoad();
            InitializeComponent();

            Title = "Details";

            FlowerImage.SetImage(
                new NSUrl(Vm.ImageUri.AbsoluteUri),
                UIImage.FromBundle("flower_256_magenta.png"));

            this.SetBinding(
                () => Vm.Model.Name)
                .WhenSourceChanges(
                    () =>
                    {
                        // iOS is quite primitive and requires layout recalculation when the content
                        // of UI elements changes. This is a good place to do that.

                        NameText.Text = Vm.Model.Name;
                        NameText.SizeToFit();
                        NameText.Frame = new CGRect(140, 75, 170, NameText.Bounds.Height);
                    });

            this.SetBinding(
                () => Vm.Model.Description)
                .WhenSourceChanges(
                    () =>
                    {
                        DescriptionText.Text = Vm.Model.Description;
                        DescriptionText.SizeToFit();
                        DescriptionText.Frame = new CGRect(0, 0, 300, DescriptionText.Bounds.Height);

                        Scroll.ContentSize = new CGSize(300, DescriptionText.Bounds.Height);
                        Scroll.SetNeedsLayout();
                    });

            SeeCommentButton.Clicked += (s, e) =>
            {
                // iOS is the only framework where we decided to split the comments
                // on a different page. This is a good example that you can easily
                // have different UI experience even though the ViewModel and Model are the same

                var controller = Vm.Model.Comments.GetController(
                    CreateCommentCell,
                    BindCommentCell);
                controller.Title = "Comments";

                var addCommentButton = new UIBarButtonItem(UIBarButtonSystemItem.Add, null);
                addCommentButton.SetCommand("Clicked", Vm.AddCommentCommand);
                controller.NavigationItem.SetRightBarButtonItem(addCommentButton, false);

                AppDelegate.MainNavigationController.PushViewController(controller, true);
            };
        }
开发者ID:timdetering,项目名称:mvvmlight,代码行数:56,代码来源:DetailsViewController.cs

示例2: ViewDidLoad

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

            // Add the add button to the navigation abr
            UIBarButtonItem btnAdd = new UIBarButtonItem();
            btnAdd.Title = "Add";
            btnAdd.SetCommand("Clicked", App.Bootstrapper.MainViewModel.NavigateToAddCommand);
            NavigationItem.RightBarButtonItem = btnAdd;
        }
开发者ID:MicrosoftDXGermany,项目名称:Cross-Platform,代码行数:10,代码来源:MainViewController.cs

示例3: ViewDidLoad

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

            // Set bindings
            NameBinding = this.SetBinding (() => tfTitle.Text)
                .UpdateSourceTrigger ("EditingDidEnd")
                .WhenSourceChanges (() => MainViewModel.Draft.Title = tfTitle.Text);

            ContentBinding = this.SetBinding (() => tfContent.Text)
                .UpdateSourceTrigger ("EditingDidEnd")
                .WhenSourceChanges (() => MainViewModel.Draft.Content = tfContent.Text);

            // Add the add button to the navigation abr
            UIBarButtonItem btnAdd = new UIBarButtonItem();
            btnAdd.Title = "Add";
            btnAdd.SetCommand("Clicked", MainViewModel.AddNoteCommand);

            NavigationItem.RightBarButtonItem = btnAdd;
        }
开发者ID:MicrosoftDXGermany,项目名称:Cross-Platform,代码行数:20,代码来源:AddViewController.cs

示例4: ViewDidLoad

        public override void ViewDidLoad()
        {
            if (NavigationParameter == null)
            {
                throw new InvalidOperationException("No parameter found after navigation");
            }

            Vm = (FlowerViewModel)NavigationParameter;

            _tableController = Vm.Model.Comments.GetController(
                CreateCommentCell,
                BindCommentCell);

            _tableController.TableView = CommentsTableView;

            AddCommentButton = new UIBarButtonItem(UIBarButtonSystemItem.Add, null);
            NavigationItem.SetRightBarButtonItem(AddCommentButton, false);
            AddCommentButton.SetCommand("Clicked", Vm.AddCommentCommand);

            base.ViewDidLoad();
        }
开发者ID:NulledLabs,项目名称:mvvmlight,代码行数:21,代码来源:SeeCommentsViewController.cs

示例5: ViewDidLoad

        public override void ViewDidLoad()
        {
            if (NavigationParameter == null)
            {
                throw new InvalidOperationException("No parameter found after navigation");
            }

            Vm = (FlowerViewModel)NavigationParameter;

            SaveCommentButton = new UIBarButtonItem(UIBarButtonSystemItem.Save, null);
            NavigationItem.SetRightBarButtonItem(SaveCommentButton, false);

            _commentBinding = this.SetBinding(
                () => CommentText.Text)
                .UpdateSourceTrigger("Changed");

            SaveCommentButton.SetCommand(
                "Clicked",
                Vm.SaveCommentCommand,
                _commentBinding);

            base.ViewDidLoad();
        }
开发者ID:NulledLabs,项目名称:mvvmlight,代码行数:23,代码来源:AddCommentViewController.cs


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