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


C# Entry.SetBinding方法代码示例

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


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

示例1: GenerateOptionLayout

        private ScrollView GenerateOptionLayout()
        {
            var stack = new StackLayout { Orientation = StackOrientation.Vertical };

            var peak = new Entry { Keyboard = Keyboard.Numeric, Placeholder = "Peak" };
            peak.SetBinding(Entry.TextProperty, OptionViewModel.PeakCommandPropertyName);
            stack.Children.Add(peak);

            var distance = new Entry { Keyboard = Keyboard.Numeric, Placeholder = "Distance" };
            distance.SetBinding(Entry.TextProperty, OptionViewModel.DistanceCommandPropertyName);
            stack.Children.Add(distance);

            var dogAllowed = new Switch();
            dogAllowed.SetBinding(Switch.IsToggledProperty, OptionViewModel.DogAllowedCommandPropertyName);
            stack.Children.Add(dogAllowed);

            var goodForKids = new Switch();
            goodForKids.SetBinding(Switch.IsToggledProperty, OptionViewModel.GoodForKidsCommandPropertyName);
            stack.Children.Add(goodForKids);

            var seasonStart = new Picker { Title = "SeasonStart" };
            foreach (var season in options.Seasons)
            {
                seasonStart.Items.Add(season.Value);
            }
            seasonStart.SetBinding(Picker.SelectedIndexProperty, OptionViewModel.SeasonStartCommandPropertyName);
            stack.Children.Add(seasonStart);

            var seasonEnd = new Picker { Title = "SeasonEnd" };
            foreach (var season in options.Seasons)
            {
                seasonEnd.Items.Add(season.Value);
            }
            seasonEnd.SetBinding(Picker.SelectedIndexProperty, OptionViewModel.SeasonEndCommandPropertyName);
            stack.Children.Add(seasonEnd);

            var trailType = new Picker() { Title = "Trail Type" };
            stack.Children.Add(trailType);
            foreach (var type in options.TrailsTypes)
            {
                trailType.Items.Add(type.Value);
            }
            trailType.SetBinding(Picker.SelectedIndexProperty, OptionViewModel.TypeCommandPropertyName);

            var trailDurationType = new Picker() { Title = "Trail Duration Type" };
            foreach (var durType in options.TrailsDurationTypes)
            {
                trailDurationType.Items.Add(durType.Value);
            }
            trailDurationType.SetBinding(Picker.SelectedIndexProperty, OptionViewModel.DurationTypeCommandPropertyName);
            stack.Children.Add(trailDurationType);

            var button = GenericsContent.GenerateDefaultButton("Update");
            button.SetBinding(Button.CommandProperty, OptionViewModel.UpdateCommandPropertyName);
            stack.Children.Add(button);

            return new ScrollView { Content = stack };
        }
开发者ID:Zepsen,项目名称:App1,代码行数:58,代码来源:OptionPage.cs

示例2: 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

示例3: App

		public App ()
		{
			var stringSettingEntry = new Entry ();
			stringSettingEntry.SetBinding (Entry.TextProperty, nameof (SettingsViewModel.SomeStringSetting));

			var boolSettingSwitch = new Switch ();
			boolSettingSwitch.SetBinding (Switch.IsToggledProperty, nameof (SettingsViewModel.SomeBoolSetting));

			// The root page of your application
			MainPage = new ContentPage {
				Content = new StackLayout {
					VerticalOptions = LayoutOptions.Center,
					Children = {
						new Label {
							Text = "Some String"
						},
						stringSettingEntry,
						new Label {
							Text = "Some Bool"
						},
						boolSettingSwitch,
					}
				}
			};

			MainPage.BindingContext = new SettingsViewModel ();
		}
开发者ID:patridge,项目名称:demos-xamarin.forms-tour,代码行数:27,代码来源:X.FPluginDemo.cs

示例4: ItemPage

        public ItemPage()
        {
            var item = new Item { Title = "First", Description = "1st item" };
            this.BindingContext = item;
            //titleEntry.BindingContext = item;

            var titleEntry = new Entry()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            titleEntry.SetBinding(Entry.TextProperty, "Title");

            Button buttonDisplay = new Button
            {
                Text = "Display Item Value",
                FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Button)),
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions = LayoutOptions.Fill
            };

            buttonDisplay.Clicked += async (sender, args) =>
            {
               await DisplayAlert("Item Object", "Title property:" +  item.Title.ToString(), "OK");
            };


            Content = new StackLayout {
                Children = { titleEntry, buttonDisplay }
             };

        }
开发者ID:mhalkovitch,项目名称:Xamarim,代码行数:32,代码来源:ItemPage.cs

示例5: 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

示例6: 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

示例7: HomePageCS

        public HomePageCS()
        {
            BindingContext = this;

            var angleEntry = new Entry { WidthRequest = 50 };
            angleEntry.SetBinding (Entry.TextProperty, "Angle");

            var image = new Image { VerticalOptions = LayoutOptions.CenterAndExpand };
            image.Source = ImageSource.FromFile ("waterfront.jpg");
            image.SetBinding (VisualElement.RotationProperty, "Angle");

            Content = new StackLayout {
                Padding = new Thickness (0, 20, 0, 0),
                Children = {
                    new Label {
                        Text = "Bindable Property Validation Callback Demo",
                        FontAttributes = FontAttributes.Bold,
                        HorizontalOptions = LayoutOptions.Center
                    },
                    new StackLayout {
                        Orientation = StackOrientation.Horizontal,
                        HorizontalOptions = LayoutOptions.Center,
                        Children = {
                            new Label { Text = "Rotation angle:" },
                            angleEntry
                        }
                    },
                    image
                }
            };
        }
开发者ID:RickySan65,项目名称:xamarin-forms-samples,代码行数:31,代码来源:HomePageCS.cs

示例8: Init

		protected override void Init ()
		{
			var entry = new Entry {
				Text = "Setec Astronomy",
				FontFamily = "Comic Sans MS",
				HorizontalTextAlignment = TextAlignment.Center,
				Keyboard = Keyboard.Chat
			};

			var label = new Label ();
			var binding = new Binding ("Text") { Source = entry };

			var otherEntry = new Entry ();
			var otherBinding = new Binding ("Text") { Source = entry, Mode = BindingMode.TwoWay };
			otherEntry.SetBinding (Entry.TextProperty, otherBinding);

			label.SetBinding (Label.TextProperty, binding);

			var explanation = new Label() {Text = @"The Text value of the entry at the top should appear in the label and entry below, regardless of whether 'IsPassword' is on. 
Changes to the value in the entry below should be reflected in the entry at the top."};

			var button = new Button { Text = "Toggle IsPassword" };
			button.Clicked += (sender, args) => { entry.IsPassword = !entry.IsPassword; };

			Content = new StackLayout {
				Children = { entry, button, explanation, label, otherEntry }
			};
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:28,代码来源:IsPasswordToggleTest.cs

示例9: AddTaxaPage

          //private bool _taxaTxtChanged;

          public AddTaxaPage(string title) {    
               var scrollView = new ScrollView();
               var contentStack = new StackLayout {
                    VerticalOptions = LayoutOptions.Start,
                    HorizontalOptions = LayoutOptions.Start
               };
               _taxaStack = new StackLayout {
                    Orientation = StackOrientation.Vertical,
                    HorizontalOptions = LayoutOptions.FillAndExpand
               };

               var numLabel = new Label { Text = "Enter Number of Taxa:" };
               _numEntry = new Entry { WidthRequest = 50 };
               _numEntry.Completed += NumTaxa_OnCompleted;
               _numEntry.Keyboard = Keyboard.Numeric;
               _numEntry.BindingContext = new EntryRestrictions();
               _numEntry.SetBinding(Entry.TextProperty, "Num1To99");
               contentStack.Children.Add(numLabel);
               contentStack.Children.Add(_numEntry);
               _noteLabel = new Label { Text = "These are the organisms you will be comparing." };
               contentStack.Children.Add(_noteLabel);
               contentStack.Children.Add(_taxaStack);
               _addTaxaBtn.Clicked += OnAddTaxa;
               _addTaxaBtn.BackgroundColor = Color.Accent;
               _addTaxaBtn.IsEnabled = false;
               _addTaxaBtn.IsVisible = false;
               contentStack.Children.Add(_addTaxaBtn);

               scrollView.Content = contentStack;
               Content = scrollView;
               Title = title;
          }
开发者ID:kflo,项目名称:phylo,代码行数:34,代码来源:AddTaxaPage.xaml.cs

示例10: TodoCategoryPage

        public TodoCategoryPage()
        {
            this.SetBinding(ContentPage.TitleProperty, "Udo");
            NavigationPage.SetHasNavigationBar(this, true);
            var toDoCategory = new TodoCategory();
            this.BindingContext = toDoCategory;

            //task name
            var nameLabel = new Label { Text = "Category Name" };
            var nameEntry = new Entry();
            nameEntry.SetBinding(Entry.TextProperty, "Name");

            //Save
            var saveButton = new Button { Text = "Save" };
            saveButton.Clicked += (sender, e) =>
            {
                var todoCategory = (TodoCategory)BindingContext;
                App.CategoryDatabase.SaveCategory(todoCategory);
                nameEntry.Text = "";

            };
            Content = new StackLayout
            {
                VerticalOptions = LayoutOptions.StartAndExpand,
                Padding = new Thickness(20),
                Children = {
                    nameLabel, nameEntry,
                    saveButton
                }
            };
        }
开发者ID:SindhoojaMullapudi,项目名称:UDo,代码行数:31,代码来源:TodoCategoryPage.cs

示例11: TodoItemPage

		public TodoItemPage ()
		{
			//this.SetBinding (ContentPage.TitleProperty, "Name");
		    this.Title = "Add Todo item";

			NavigationPage.SetHasNavigationBar (this, true);
			var nameLabel = new Label { Text = "Name" };
			var nameEntry = new Entry ();
			
			nameEntry.SetBinding (Entry.TextProperty, "Name");

			var notesLabel = new Label { Text = "Notes" };
			var notesEntry = new Entry ();
			notesEntry.SetBinding (Entry.TextProperty, "Notes");

			var doneLabel = new Label { Text = "Done" };
			var doneEntry = new Switch ();
			doneEntry.SetBinding (Switch.IsToggledProperty, "Done");

			var saveButton = new Button { Text = "Save" };
			saveButton.Clicked += (sender, e) => {
				var todoItem = (TodoItem)BindingContext;
				App.Database.SaveItem(todoItem);
				this.Navigation.PopAsync();
			};

			var deleteButton = new Button { Text = "Delete" };
			deleteButton.Clicked += (sender, e) => {
				var todoItem = (TodoItem)BindingContext;
				App.Database.DeleteItem(todoItem.ID);
                this.Navigation.PopAsync();
			};
							
			var cancelButton = new Button { Text = "Cancel" };
			cancelButton.Clicked += (sender, e) => {
				var todoItem = (TodoItem)BindingContext;
                this.Navigation.PopAsync();
			};


			var speakButton = new Button { Text = "Speak" };
			speakButton.Clicked += (sender, e) => {
				var todoItem = (TodoItem)BindingContext;
				DependencyService.Get<ITextToSpeech>().Speak(todoItem.Name + " " + todoItem.Notes);
			};

			Content = new StackLayout {
				VerticalOptions = LayoutOptions.StartAndExpand,
				Padding = new Thickness(20),
				Children = {
					nameLabel, nameEntry, 
					notesLabel, notesEntry,
					doneLabel, doneEntry,
					saveButton, deleteButton, cancelButton,
					speakButton
				}
			};
		}
开发者ID:DIGIHOME-MK,项目名称:Xamarin-forms-winrt,代码行数:58,代码来源:TodoItemPage.cs

示例12: GenerateMainPage

        private StackLayout GenerateMainPage()
        {
            var stack = new StackLayout { Padding = new Thickness(50, 0), Spacing = 10 };

            var labelFName = GenerateDefaultLabel("First name");
            var labelLName = GenerateDefaultLabel("Last name");
            var labelEmail = GenerateDefaultLabel("Email");

            var entryFName = new Entry() { HorizontalTextAlignment = TextAlignment.Center };
            entryFName.SetBinding(Entry.TextProperty, EmployeerViewModel.FirstNamePropName);
            entryFName.SetBinding(Entry.BackgroundColorProperty, EmployeerViewModel.FirstNameBCPropName);

            var entryLName = new Entry() { HorizontalTextAlignment = TextAlignment.Center };
            entryLName.SetBinding(Entry.TextProperty, EmployeerViewModel.LastNamePropName);
            entryLName.SetBinding(Entry.BackgroundColorProperty, EmployeerViewModel.LastNameBCPropName);

            var entryEmail = new Entry() { HorizontalTextAlignment = TextAlignment.Center };
            entryEmail.SetBinding(Entry.TextProperty, EmployeerViewModel.EmailPropName);
            entryEmail.SetBinding(Entry.BackgroundColorProperty, EmployeerViewModel.EmailBCPropName);

            var entryId = new Entry() { HorizontalTextAlignment = TextAlignment.Center };
            entryId.SetBinding(Entry.TextProperty, EmployeerViewModel.IdPropName);

            var btnGet = GetDefaultButton("Get");
            btnGet.SetBinding(Button.CommandProperty, EmployeerViewModel.GetCommandPropertyName);

            var btnAdd = GetDefaultButton("Add");
            btnAdd.SetBinding(Button.CommandProperty, EmployeerViewModel.AddCommandPropertyName);

            stack.Children.Add(labelFName);
            stack.Children.Add(entryFName);

            stack.Children.Add(labelLName);
            stack.Children.Add(entryLName);

            stack.Children.Add(labelEmail);
            stack.Children.Add(entryEmail);

            stack.Children.Add(entryId);

            stack.Children.Add(btnGet);
            stack.Children.Add(btnAdd);

            return stack;
        }
开发者ID:Zepsen,项目名称:CSLA2,代码行数:45,代码来源:MainPage.cs

示例13: BetPage

        public BetPage()
        {
            try{
            this.Title = "Test Title";

            NavigationPage.SetHasNavigationBar (this, true);
            var numbersLabel = new Label { Text = "Numbers" };
            var numbersEntry = new Entry ();

            numbersEntry.SetBinding(Entry.TextProperty, "Numbers");

            var starsLabel = new Label { Text = "Stars" };
            var starsEntry = new Entry ();

            starsEntry.SetBinding(Entry.TextProperty, "Stars");

            var dateLabel = new Label { Text = "Date" };
            var dateEntry = new DatePicker ();
            dateEntry.SetBinding (DatePicker.DateProperty, new Binding ("Date", BindingMode.TwoWay, new DateTimeToStringConverter (), null));

            var saveButton = new Button { Text = "Save" };
            saveButton.Clicked += (sender, e) => {
                var BetObject = (Bet)BindingContext;
                App.Database.SaveBet(BetObject);
                this.Navigation.PopAsync();

            };

            var deleteButton = new Button { Text = "Delete" };
            deleteButton.Clicked += (sender, e) => {
                var BetObject = (Bet)BindingContext;
                App.Database.DeleteBet(BetObject.ID);
                this.Navigation.PopAsync();

            };

            var cancelButton = new Button { Text = "Cancel" };
            cancelButton.Clicked += (sender, e) => {
                this.Navigation.PopAsync();
            };

            Content = new StackLayout {
                VerticalOptions = LayoutOptions.StartAndExpand,
                Padding = new Thickness(20),
                Children = {
                    numbersLabel, numbersEntry,
                    starsLabel, starsEntry,
                    /*dateLabel, dateEntry,*/
                    saveButton, deleteButton, cancelButton
                }
            };
            }
            catch(Exception exc){
                System.Diagnostics.Debug.WriteLine (exc);
            }
        }
开发者ID:joaodealmeida,项目名称:EuromillionsDraws,代码行数:56,代码来源:BetPage.cs

示例14: Main2Page

        public Main2Page()
        {
            Button goButton;
            Entry searchEntry;
            StackLayout mainLayout;
            Title = "Movies Sample";

            Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);

            var searchLayout = new StackLayout
            {
                Spacing = 10,
                Orientation = StackOrientation.Horizontal,
            };

            searchLayout.Children.Add(searchEntry = new Entry
            {
                Placeholder = "Movie Name",
                HorizontalOptions = LayoutOptions.FillAndExpand
            });
            searchLayout.Children.Add(goButton = new Button
            {
                Text = "Search", IsEnabled = true,
                HorizontalOptions = LayoutOptions.End
            });

            Content = mainLayout = new StackLayout
            {
                Padding = new Thickness(10),
                Spacing = 10,
                Orientation = StackOrientation.Vertical,
            };

            
            mainLayout.Children.Add(searchLayout);
            
            var movieListView = new ListView
            {
                ItemTemplate = new DataTemplate(typeof(ImageCell))
            };

            mainLayout.Children.Add(movieListView);
            
            searchEntry.SetBinding(Entry.TextProperty, new Binding("SearchString"));
            goButton.SetBinding(Button.CommandProperty, new Binding("GetMoviesCommand"));
            movieListView.SetBinding(ListView.ItemsSourceProperty, new Binding("Movies"));
            movieListView.SetBinding(ListView.SelectedItemProperty, new Binding("SelectedMovie"));
            movieListView.ItemTemplate.SetBinding(ImageCell.TextProperty, new Binding("Title"));
            movieListView.ItemTemplate.SetBinding(ImageCell.ImageSourceProperty, new Binding("PosterUrl"));
            movieListView.ItemTemplate.SetBinding(ImageCell.DetailProperty, new Binding("Score"));
             
        }
开发者ID:Milton761,项目名称:EduticNow,代码行数:52,代码来源:Main2Page.cs

示例15: LoginPage

		public LoginPage()
		{
			BindingContext = new Login();

			var layout = new StackLayout { Padding = 10 };

			load = new ActivityIndicator {
				HorizontalOptions = LayoutOptions.Center,
				VerticalOptions = LayoutOptions.Center,
				IsRunning = true,
				IsVisible = false,
				Color = Color.Blue
			};

			var loginImage = new Image ();
			loginImage.Source = ImageSource.FromFile("login_image.png");

			layout.Children.Add(loginImage);

			var username = new Entry { Placeholder = "Username" };

			username.SetBinding(Entry.TextProperty, "Username" );
			layout.Children.Add(username);

			var password = new Entry { Placeholder = "Password", IsPassword = true };

			password.SetBinding(Entry.TextProperty, "Password");
			layout.Children.Add(password);



			var button = new Button { Text = "Sign In" };
			var button2 = new Button { Text = "Register" };

			if (Device.OS == TargetPlatform.iOS) {
				button.TextColor = Color.Black;
				button2.TextColor = Color.Black;
			} else {
				button.TextColor = Color.White;
				button2.TextColor = Color.White;
			}


			layout.Children.Add(button);
			layout.Children.Add (button2);

			Content = new ScrollView { Content = layout };
			button.Clicked += Login;
			button2.Clicked += Register;
		}
开发者ID:joaodealmeida,项目名称:EuromillionsDraws,代码行数:50,代码来源:LoginPage.cs


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