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


C# Button.SetBinding方法代码示例

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


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

示例1: App

        public App()
        {
            var tstButton = new Button
            {
            };
            var slider = new Slider
            {
                Minimum = 0,
                Maximum = 1,
                Value = 1,
                VerticalOptions = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
            };

            tstButton.SetBinding(VisualElement.OpacityProperty, new Binding("Value", source: slider));
            tstButton.SetBinding(Button.TextProperty, new Binding("Value", source: slider, stringFormat: "Opacity: {0:0.00}"));

            // The root page of your application
            MainPage = new ContentPage
            {
                Content = new StackLayout
                {
                    Padding = new Thickness(10, 10),
                    VerticalOptions = LayoutOptions.FillAndExpand,
                    Children = {
                        tstButton,
                        slider
                    }
                }
            };
        }
开发者ID:powerdude,项目名称:xamarin-forms-xna,代码行数:31,代码来源:App.cs

示例2: updateView

        private void updateView()
        {



            bAddFriend = new Button
            {
                Text = "+",
                FontAttributes = FontAttributes.Bold,
                TextColor = ch.fromStringToColor("gray"),
                BackgroundColor = ch.fromStringToColor("white"),
                HorizontalOptions = LayoutOptions.EndAndExpand,
                VerticalOptions = LayoutOptions.Center
            };
            bAddFriend.Clicked += BAddFriend_Clicked;
            bAddFriend.SetBinding(Button.IsVisibleProperty, "NotFriends");
            bFriendsIndicator = new Button
            {
                BorderRadius = 100,
                HeightRequest = 20,
                WidthRequest = 20,
                HorizontalOptions = LayoutOptions.EndAndExpand,
                VerticalOptions = LayoutOptions.Center,
                BackgroundColor = ch.fromStringToColor("yellow")

            };
            bFriendsIndicator.SetBinding(Button.BackgroundColorProperty, "FriendIndicator");
            bFriendsIndicator.SetBinding(Button.IsVisibleProperty, "AreFriends");
            View = new StackLayout
            {
                Children ={
                    iEmoji,
                    lUsername,
                    bAddFriend,
                    new StackLayout
                    {
                        Children =
                        {
                            bFriendsIndicator
                        },
                        HorizontalOptions = LayoutOptions.EndAndExpand,
                        VerticalOptions = LayoutOptions.Center,
                        Padding = new Thickness(0,0,5,0)

                    }

                },
                Orientation = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Padding = new Thickness(10, 0, 10, 0),
                BackgroundColor = ch.fromStringToColor("white")
            };
        }
开发者ID:bpeck81,项目名称:Cloudclub_v1,代码行数:53,代码来源:ClubMemberViewCell.cs

示例3: LoginPage

        public LoginPage()
        {
            BindingContext = new LoginViewModel(Navigation);

            var layout = new StackLayout { Padding = 10 };

            var label = new Label
            {
                Text = "Login",
                FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
                TextColor = Color.White,
                VerticalOptions = LayoutOptions.Start,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment = TextAlignment.Center,
            };

            layout.Children.Add(label);

            var username = new Entry { Placeholder = "Username" };
            username.SetBinding(Entry.TextProperty, LoginViewModel.UsernamePropertyName);
            layout.Children.Add(username);

            var password = new Entry { Placeholder = "Password", IsPassword = true };
            password.SetBinding(Entry.TextProperty, LoginViewModel.PasswordPropertyName);
            layout.Children.Add(password);

            var button = new Button { Text = "Sign In", TextColor = Color.White };
            button.SetBinding(Button.CommandProperty, LoginViewModel.LoginCommandPropertyName);

            layout.Children.Add(button);

            Content = new ScrollView { Content = layout };
        }
开发者ID:Zepsen,项目名称:App1,代码行数:33,代码来源:LoginPage.cs

示例4: HomePage

		public HomePage ()
		{
			// setup your ViewModel
			ViewModel = new HomePageViewModel
			{
				ButtonText = "Click Me!"
			};
			// Set the binding context to the newly created ViewModel
			BindingContext = ViewModel;

			// the button is what we're going to use to trigger a long running Async task
			// we're also going to bind the button text so that we can see the binding in action
			var actionButton = new Button();
			actionButton.SetBinding(Button.TextProperty, "ButtonText");
			actionButton.Clicked += async (sender, args) => await SomeLongRunningTaskAsync();

			// here's your activity indicator, it's bound to the IsBusy property of the BaseViewModel
			// those bindings are on both the visibility property as well as the IsRunning property
			var activityIndicator = new ActivityIndicator
			{
				Color = Color.Black,
			};
			activityIndicator.SetBinding(ActivityIndicator.IsVisibleProperty, "IsBusy");
			activityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsBusy");

			// return the layout that includes all the above elements
			Content = new StackLayout
			{
				HorizontalOptions = LayoutOptions.FillAndExpand,
				VerticalOptions = LayoutOptions.FillAndExpand,
				BackgroundColor = Color.White,
				Children = {actionButton, activityIndicator}
			};
		}
开发者ID:fabianwilliams,项目名称:HowToActivityIndicatorInCode,代码行数:34,代码来源:HomePage.cs

示例5: ProductCell

        //        public EventArgs e = null;
        //        public event ButtonClickEvent ClickListener;
        //        public delegate void ButtonClickEvent (ProductCell m, EventArgs e);
        //ButtonClickEvent Listener
        public ProductCell()
        {
            //instantiate each of our views
            //ClickListener += Listener;
            StackLayout cellWrapper = new StackLayout ();
            StackLayout horizontalLayout = new StackLayout ();
            this.Height = 141.5;
            Label left = new Label ();
            left.VerticalOptions = LayoutOptions.CenterAndExpand;
            Label count = new Label ();
            count.VerticalOptions = LayoutOptions.CenterAndExpand;
            Button plus = new Button ();
            Button minus = new Button ();
            plus.Text = "+";
            minus.Text = "-";
            minus.IsEnabled = false;
            //			plus.Clicked += AddButtonClicked;
            //set bindings
            left.SetBinding (Label.TextProperty, "title");
            plus.SetBinding (Button.CommandProperty, "id");
            //Set properties for desired design
            cellWrapper.BackgroundColor = Color.FromHex ("#eee");
            horizontalLayout.Orientation = StackOrientation.Horizontal;
            left.TextColor = Color.FromHex ("#f35e20");
            count.TextColor = Color.FromHex ("#f35e20");
            count.Text = "0";
            //add views to the view hierarchy
            horizontalLayout.Children.Add (left);
            horizontalLayout.Children.Add (plus);
            horizontalLayout.Children.Add (count);
            horizontalLayout.Children.Add (minus);

            cellWrapper.Children.Add (horizontalLayout);
            View = cellWrapper;
        }
开发者ID:sliderif,项目名称:Coffetab,代码行数:39,代码来源:ProductCell.cs

示例6: OnCreateNavigationView

        protected View OnCreateNavigationView()
        {
            var backButton = new Button {
                Text = "Back",
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.FillAndExpand
            };
            backButton.SetBinding (Button.CommandProperty, new Binding ("NavigateBack", BindingMode.OneWay));

            var submitButton = new Button {
                Text = "Next",
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.FillAndExpand
            };
            submitButton.SetBinding (Button.CommandProperty, new Binding ("SubmitPage", BindingMode.OneWay));

            var stackLayout = new StackLayout {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.End,
                Orientation = StackOrientation.Horizontal,
                Children = {
                    backButton,
                    submitButton
                }
            };

            return stackLayout;
        }
开发者ID:davidjcaton,项目名称:glowingbrain-data-capture,代码行数:28,代码来源:StandardSurveyPage.cs

示例7: FeedOverview

        public FeedOverview()
        {
            var refreshButton = new Button {
            HorizontalOptions = LayoutOptions.FillAndExpand,
            VerticalOptions = LayoutOptions.Center,
            Text = "Refresh"
              };
              refreshButton.SetBinding(Button.CommandProperty, "RefreshCommand");

              var template = new DataTemplate(typeof(TextCell));
              // We can set data bindings to our supplied objects.
              template.SetBinding(TextCell.TextProperty, "Title");
              template.SetBinding(TextCell.DetailProperty, "Description");

              var listView = new ListView {ItemTemplate = template};
              listView.SetBinding(ListView.ItemsSourceProperty, "FeedItems");

              // Push the list view down below the status bar on iOS.
              Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);
              Content = new Grid {
            BindingContext = new FeedReaderViewModel(),

            RowDefinitions = new RowDefinitionCollection {
             new RowDefinition { Height = new GridLength (1, GridUnitType.Star) },
             new RowDefinition { Height = new GridLength (0, GridUnitType.Auto) },

               },
            Children = {
               new ViewWithGridPosition(listView, 0,0),
               new ViewWithGridPosition(refreshButton, 1,0)
             },
              };
        }
开发者ID:dotnetautor,项目名称:FeedReader2015,代码行数:33,代码来源:FeedOverview.cs

示例8: FirstContentView

        public FirstContentView()
        {
            var l = new Label();

            Icon = "settings_vertical.png";

            l.TextColor = Color.FromHex("BBBBBB");
            l.SetBinding(Label.TextProperty, "Title");

            var label = new ContentView
            {
                Padding = new Thickness(10, 0, 0, 5),
                Content = l
            };

            var b = new Button();
            b.Text = "Next page";
            b.SetBinding(Button.CommandProperty, "NextPageCommand");

            var layout = new StackLayout();

            layout.Children.Add(label);
            layout.Children.Add(b);

            Content = layout;
        }
开发者ID:jakkaj,项目名称:Xamling-Core,代码行数:26,代码来源:FirstContentView.cs

示例9: MyPage

 public MyPage()
 {
     Button buttonToUpdate = new Button {Text = "Image Button",  Image = "icon.png"};
     Button UpdatesList = new Button {Text="Add Item to list"};
     buttonToUpdate.SetBinding (Button.ImageProperty, new Binding("ImagePath"));
     UpdatesList.Clicked += (sender,e) => {
         listToWatch.Add (DateTime.Now.ToString());
     };
     listToWatch.CollectionChanged+=(sender,e)=>{
         if(	listToWatch.Count%2==1)
         {
             ImagePath="noci.png";
         }
         else
         {
             ImagePath="icon.png";
         }
     };
     Content = new StackLayout {
         Children = {
             buttonToUpdate,
             UpdatesList
         }
     };
     Content.BindingContext = this;
 }
开发者ID:DavidStrickland0,项目名称:Xamarin-Forms-Samples,代码行数:26,代码来源:MyPage.cs

示例10: InitialPage

        public InitialPage()
        {
            BindingContext = new InitialPageModel (this.Navigation);

            Title = "Welcome to Peter";

            Label timeLabel = new Label {
                HorizontalOptions = LayoutOptions.Center,
            };
            timeLabel.SetBinding<InitialPageModel> (Label.TextProperty, vm => vm.DrinkingHoursDisplay);

            Slider timeSlider = new Slider (1, 24, 5) {
                HorizontalOptions = LayoutOptions.FillAndExpand,
            };
            timeSlider.SetBinding<InitialPageModel> (Slider.ValueProperty, vm => vm.DrinkingHours, BindingMode.TwoWay);

            Button pressMe = new Button {
                Text = "Help Peter",
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                VerticalOptions = LayoutOptions.CenterAndExpand,
                FontSize = 60,
                HeightRequest = 200,
                BackgroundColor = Color.Yellow,
            };
            pressMe.SetBinding<InitialPageModel> (Button.CommandProperty, vm => vm.PressMeCommand);

            Content = new StackLayout {
                Children = {
                    timeLabel,
                    timeSlider,
                    pressMe,
                }
            };
        }
开发者ID:RickNabb,项目名称:Peter,代码行数:34,代码来源:InitialPage.cs

示例11: FilterPage

		public FilterPage ()
		{
			this.Icon = "slideout.png";
			this.Title = "Filter";

			_scope = App.AutoFacContainer.BeginLifetimeScope();

			var vm = _scope.Resolve<FilterViewModel> ();

			BindingContext = vm;

			var layout = new StackLayout ();

			layout.Children.Add (new Label() {Text = "Enter a filter"});
			layout.Children.Add (new Label() {Text = "Subject"});
			var subjectEntry = new Entry();
			subjectEntry.SetBinding (Entry.TextProperty, "Subject");
			layout.Children.Add (subjectEntry);
			var button = new Button () { Text = "Apply Filter" };
			button.SetBinding (Button.CommandProperty, "FilterMeasures");
			layout.Children.Add (button);

			Content = layout;


		}
开发者ID:jscote,项目名称:Meezure,代码行数:26,代码来源:FilterPage.xaml.cs

示例12: HomePage

        /// <summary>
        /// Constructor
        /// </summary>
        public HomePage()
        {
            BackgroundImage = "bg.png";
            var masterLayout = new StackLayout {
                Orientation = StackOrientation.Vertical,
                Spacing = 10
            };

            // Start Button
            var startButton = new Button { Text = "スタート", HorizontalOptions = LayoutOptions.Center };
            masterLayout.Children.Add(startButton);

            // Text followed by two auto expanding text areas
            var row = new StackLayout { Orientation = StackOrientation.Horizontal, Spacing = 10, Padding = new Thickness(10, 0, 10, 0) };
            row.Children.Add(new Label { Text = "範囲:" });
            masterLayout.Children.Add(row);
            var grid = new Grid();
            grid.HorizontalOptions = LayoutOptions.FillAndExpand;
            grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) });
            grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) });
            var lowerBoundField = new Entry();
            var upperBoundField = new Entry();
            grid.Children.Add(lowerBoundField, 0, 0);
            grid.Children.Add(upperBoundField, 1, 0);
            row.Children.Add(grid);

            // Data binding
            upperBoundField.SetBinding(Entry.TextProperty, new Binding("UpperBoundText", BindingMode.TwoWay));
            lowerBoundField.SetBinding(Entry.TextProperty, new Binding("LowerBoundText", BindingMode.TwoWay));
            startButton.SetBinding(Button.CommandProperty, new Binding("StartPracticeCommand", BindingMode.OneWay));

            Content = masterLayout;
        }
开发者ID:borrrden,项目名称:SayNumbers,代码行数:36,代码来源:HomePage.cs

示例13: PracticePage

        /// <summary>
        /// Constructor
        /// </summary>
        public PracticePage()
        {
            BackgroundImage = "bg.png";
            var stackLayout = new StackLayout {
                Orientation = StackOrientation.Vertical,
                VerticalOptions = LayoutOptions.CenterAndExpand,
                Spacing = 15 };

            // Question
            var problemText = new Label { XAlign = TextAlignment.Center };
            problemText.SetBinding(Label.TextProperty, new Binding("ProblemText", BindingMode.OneWay));
            stackLayout.Children.Add(problemText);

            // Answer Button
            var answerButton = new Button { Text = "答え", HorizontalOptions = LayoutOptions.Center };
            answerButton.SetBinding(Button.CommandProperty, new Binding("AnswerButtonCommand", BindingMode.OneWay));
            stackLayout.Children.Add(answerButton);

            //Answer Text
            var answerText = new Label { XAlign = TextAlignment.Center };
            answerText.SetBinding(Label.TextProperty, new Binding("AnswerText", BindingMode.OneWay));
            stackLayout.Children.Add(answerText);

            Content = stackLayout;
        }
开发者ID:borrrden,项目名称:SayNumbers,代码行数:28,代码来源:PracticePage.cs

示例14: LoginPage

        public LoginPage(ViewModelBase viewModel) : base(viewModel)
        {
            Label lblLogin = new Label
            {
                Text = "Login",
                Font = Font.BoldSystemFontOfSize(36),
                HorizontalOptions = LayoutOptions.Center
            };

            Button btnLogin = new Button();
            btnLogin.Text = "Entrar";
            btnLogin.SetBinding(IsEnabledProperty, new Binding("IsBusy", converter: new InverterConverter()));
            btnLogin.SetBinding(Button.CommandProperty, new Binding("EntrarCommand"));
            btnLogin.BackgroundColor = Color.Green;
            btnLogin.TextColor = Color.White;

            Entry txtNome = new Entry
            {
                Keyboard = Keyboard.Text,
                Placeholder = "E-mail",
            };
            txtNome.SetBinding(Entry.TextProperty, new Binding("Email", BindingMode.TwoWay));

            Entry txtSenha = new Entry
            {
                Keyboard = Keyboard.Text,
                IsPassword = true,
                Placeholder = "Senha",
            };
            txtSenha.SetBinding(Entry.TextProperty, new Binding("Senha", BindingMode.TwoWay));

            //Configura layout para barra de status do iOS.
            Padding = new Thickness(10, Device.OnPlatform(iOS: 20, Android: 0, WinPhone: 0), 10, 5);

            Content = new StackLayout
            {
                Children =
                        {
                            lblLogin,
                            txtNome,
                            txtSenha,
                            btnLogin
                        }
            };
        }
开发者ID:alancaetano,项目名称:AgendaOnline,代码行数:45,代码来源:LoginPage.cs

示例15: GroupPage

        public GroupPage(RootPage rootPage)
        {
            _rootPage = rootPage;
            NavigationPage.SetHasNavigationBar (this, false);

            //TODO : Inject Groups
            _db = new GroupsterDatabase();

            _viewModel = new GroupLoadingViewModel (Navigation, _db.GetItems<Group>(), rootPage);
            BindingContext = _viewModel;

            var statusMessageLabel = new LargeLabel {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions = LayoutOptions.Center,
                TextColor = Color.White,
            };

            statusMessageLabel.SetBinding<GroupLoadingViewModel> (Label.TextProperty, vm => vm.StatusMessage);

            var stackLayout = new StackLayout {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions = LayoutOptions.Center,
                Spacing = 10
            };

            var loadingImage = new Image ();

            loadingImage.SetBinding<GroupLoadingViewModel> (Image.SourceProperty, vm => vm.LoadingImage);

            var refreshButton = new Button{ Text = "Refresh", HorizontalOptions = LayoutOptions.Center };

            refreshButton.SetBinding<GroupLoadingViewModel> (Button.CommandProperty, vm => vm.GetGroupCommand);
            refreshButton.SetBinding<GroupLoadingViewModel> (VisualElement.IsVisibleProperty, vm => vm.IsRefreshButtonVisible);

            var activityIndicator = new ActivityIndicator{ IsRunning = true };

            activityIndicator.SetBinding<GroupLoadingViewModel> (VisualElement.IsVisibleProperty, vm => vm.IsActivityIndicatorVisible);

            stackLayout.Children.Add (loadingImage);
            stackLayout.Children.Add (statusMessageLabel);
            stackLayout.Children.Add (activityIndicator);
            stackLayout.Children.Add (refreshButton);

            Content = stackLayout;
        }
开发者ID:jsbuck,项目名称:Groupster,代码行数:45,代码来源:GroupPage.cs


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