當前位置: 首頁>>代碼示例>>C#>>正文


C# Forms.Picker類代碼示例

本文整理匯總了C#中Xamarin.Forms.Picker的典型用法代碼示例。如果您正苦於以下問題:C# Picker類的具體用法?C# Picker怎麽用?C# Picker使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Picker類屬於Xamarin.Forms命名空間,在下文中一共展示了Picker類的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: App

        public App()
        {
            Picker pickerArrival = new Picker ();
            pickerArrival.Items.Add ("Android");
            pickerArrival.Items.Add ("iOS");
            pickerArrival.Items.Add ("Windows Phone");

            Button bt = new Button {
                Text = "Select OS",
            };

            bt.Clicked += (e, sender) => {
                Console.WriteLine ("Selected item: " + pickerArrival.Items [pickerArrival.SelectedIndex] +
                " - index: " + pickerArrival.SelectedIndex);
            };

            // The root page of your application
            MainPage = new ContentPage {
                Content = new StackLayout {
                    VerticalOptions = LayoutOptions.Center,
                    Children = {
                        pickerArrival,
                        bt
                    }
                }
            };
        }
開發者ID:NouriTj,項目名稱:Xamarin,代碼行數:27,代碼來源:CustomPiker.cs

示例3: InitializeComponent

 private void InitializeComponent() {
     this.LoadFromXaml(typeof(MeasurementConverter));
     CfPicker = this.FindByName<Picker>("CfPicker");
     CfEntry = this.FindByName<Entry>("CfEntry");
     CtPicker = this.FindByName<Picker>("CtPicker");
     CtLabel = this.FindByName<Label>("CtLabel");
 }
開發者ID:MobileRez,項目名稱:XFXamlClass,代碼行數:7,代碼來源:MeasurementConverter.xaml.g.cs

示例4: createList

        public static ViewCell createList(List<string> source, string Label)
        {
            Picker picker = new Picker
            {
                Title = Label,
                VerticalOptions = LayoutOptions.EndAndExpand
            };

            foreach (var item in source)
            {
                picker.Items.Add(item);
            }

            return new ViewCell()
            {
                View = new StackLayout
                {
                    Orientation = StackOrientation.Horizontal,
                    Spacing = 0,
                    Children = {
                       picker

                    }
                }
            };
        }
開發者ID:renatojuniorbh,項目名稱:IconMasterDetail,代碼行數:26,代碼來源:Components.cs

示例5: JobCodeLayout

		public JobCodeLayout (List<ProjectCode> codes)
		{
			jobEntry = new Entry {
				Placeholder = "Enter job",
				Keyboard = Keyboard.Numeric,
				HorizontalOptions = LayoutOptions.FillAndExpand
			};

			codePicker = new Picker {
				Title = "Select Code",
				HorizontalOptions = LayoutOptions.FillAndExpand
			};
			var billableCodes = codes;
			if (billableCodes.Any ()) {
				foreach (var x in billableCodes) {
					codePicker.Items.Add (x.code_ID);
				}
			} else {
				codePicker.Items.Add ("Default Code");
			}

			this.HorizontalOptions = LayoutOptions.FillAndExpand;
			this.Orientation = StackOrientation.Horizontal;
			this.Children.Add (jobEntry);
			this.Children.Add (codePicker);
		}
開發者ID:pablomferrari,項目名稱:ETCTimeApp,代碼行數:26,代碼來源:JobCodeLayout.cs

示例6: networkedUI

		public void networkedUI(){
			var upSpeed = new Label
			{
				Text = "Update Speed",
				FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
				FontAttributes = FontAttributes.Bold,
			};

			picker = new Picker
			{
				VerticalOptions = LayoutOptions.Center
			};
			var data = DataManager.getInstance ();

			picker.SelectedIndexChanged += (sender, args) =>
			data.setUpdateSpeed (updateData [picker.SelectedIndex]);

			foreach (string datamember in updateData) {
				picker.Items.Add (datamember);
			}
			var stackLayout = new StackLayout ();
			stackLayout.Children.Add (settings);
			stackLayout.Children.Add (upSpeed);
			stackLayout.Children.Add (picker);
			Content = stackLayout;
			setSettings ();

		}
開發者ID:r0345,項目名稱:EIMA,代碼行數:28,代碼來源:SettingsPage.cs

示例7: SetColors

 private void SetColors(Picker picker)
 {
     foreach (var color in Configurations.ColorNames)
     {
         picker.Items.Add(color);
     }
 }
開發者ID:sarahonorato,項目名稱:Signature_PDF_Android,代碼行數:7,代碼來源:SignaturePadConfigView.xaml.cs

示例8: MultipleChoiceQuestion

		public MultipleChoiceQuestion ()
		{
			Title = "Multiple Choice";

			Label q1 = new Label{ Text = "Identify the visual field defect below." };

			var answers = new String[]{"Choose an option", "Bitemporal hemianopia", "Binasal hemianopia", "Central scotoma", "Right homonymous hemianopia", "Temporal homonymous hemianopia"};

			Picker q1a = new Picker ();

			foreach (var a in answers) {
				q1a.Items.Add (a);
			}

			var button = new Button {Text="Submit"};
			button.Clicked += (object sender, EventArgs e) =>  {
				if(q1a.SelectedIndex == 1){
					DisplayAlert("Correct!", "Well done, that's the right answer", "OK");
				}else{
					DisplayAlert("Incorrect", String.Format("The correct answer is {0}", answers[1]), "OK");
				}
			};

			Content = new StackLayout { 
				Children = {
					q1,
					new Image{
						Source = ImageSource.FromUri(new Uri("http://i.imgur.com/q7l03ZG.png"))
					},
					q1a,
					button
				}
			};
		}
開發者ID:JosephRedfern,項目名稱:EyeZapApp,代碼行數:34,代碼來源:MultipleChoiceQuestion.cs

示例9: InitPicker

 internal void InitPicker(Picker picker)
 {
     foreach (string colorName in _nameToColor.Keys)
     {
         picker.Items.Add(colorName);
     }
 }
開發者ID:ahmedalejo,項目名稱:XamlFormsGallery,代碼行數:7,代碼來源:PickerDemoViewModel.cs

示例10: InitializeComponent

 private void InitializeComponent() {
     this.LoadFromXaml(typeof(ExportPage));
     grid = this.FindByName<global::DevExpress.Mobile.DataGrid.GridControl>("grid");
     cbExportType = this.FindByName<Picker>("cbExportType");
     btnExport = this.FindByName<Button>("btnExport");
     txtPath = this.FindByName<Label>("txtPath");
     btnOpen = this.FindByName<Button>("btnOpen");
 }
開發者ID:RMDesenvolvimento,項目名稱:Xamarin,代碼行數:8,代碼來源:DevExpress.GridDemo.Modules.ExportPage.xaml.g.cs

示例11: CompareSelectedIndex

        private bool CompareSelectedIndex(Picker myPicker, string name)
        {
            if (myPicker.SelectedIndex == -1)
                return false;


            return myPicker.Items[myPicker.SelectedIndex] == name;
        }
開發者ID:mgolois,項目名稱:DivineChMS,代碼行數:8,代碼來源:NewMemberView.xaml.cs

示例12: InitializeComponent

 private void InitializeComponent()
 {
     this.LoadFromXaml(typeof(MunitConverter));
     startPicker = this.FindByName<Picker>("startPicker");
     startEntry = this.FindByName<Entry>("startEntry");
     endPicker = this.FindByName<Picker>("endPicker");
     endLabel = this.FindByName<Label>("endLabel");
 }
開發者ID:DanCaveman,項目名稱:XFXamlClass,代碼行數:8,代碼來源:MunitConverter.xaml.g.cs

示例13: RaffleListPage

        // Can give some params default value later!!
        public RaffleListPage(bool isLocationDetected, IList<RaffleLocation> raffleLocations, RaffleLocation userSelectedLocation, GeonamesCountrySubdivision countrySubdivision, bool includeSocialMedia)
        {
            InitializeComponent();
            NavigationPage.SetHasBackButton(this, false);
            Title = "Raffle List";

            LocationDetected = isLocationDetected;
            IncludeSocialMedia = includeSocialMedia;
            _viewModel = new RaffleListViewModel(isLocationDetected, raffleLocations, userSelectedLocation, countrySubdivision);

            var locationPicker = new Picker();
            locationPicker.HorizontalOptions = LayoutOptions.Center;
            layout.Children.Add(locationPicker);

            locationPicker.Items.Add(_viewModel.LocationName);
            locationPicker.SelectedIndex = 0;
            locationPicker.IsEnabled = false;

            if (_viewModel.RaffleLocation == null) // only happen when locationDetected == true
            {
                layout.Children.Add(new StackLayout
                    {
                        Children =
                        { new Label
                            {
                                Text = "Sorry. There is no available raffle at your location.",
                                HorizontalOptions = LayoutOptions.CenterAndExpand,
                                VerticalOptions = LayoutOptions.CenterAndExpand,
                            }
                        },
                        Padding = new Thickness(20, 0, 20, 0),
                        VerticalOptions = LayoutOptions.CenterAndExpand,
                    }
                );
            }
            else
            {
                GetRaffleEventsAndCreateList(_viewModel.LocationName);
            }

            // Previous UX
//            else
//            {
//                foreach (var location in raffleLocations)
//                {
//                    locationPicker.Items.Add(location.Name);
//                }
//                locationPicker.IsEnabled = true;
//                locationPicker.SelectedIndexChanged += (sender, e) =>
//                {
//                    if (layout.Children.Count == 2)
//                    {
//                        layout.Children.RemoveAt(1);
//                    }
//                    GetRaffleEventsAndCreateList(locationPicker.Items[locationPicker.SelectedIndex]);
//                };
//            }
        }
開發者ID:elschihyi,項目名稱:Tap5050Buyer,代碼行數:59,代碼來源:RaffleListPage.xaml.cs

示例14: Settings

        public Settings()
        {
            Title = "Juego de Memoria";
            Icon = "house.png";

            StackLayout panel = new StackLayout
            {
                VerticalOptions = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Orientation = StackOrientation.Vertical,
                Spacing = 10,
                Padding = new Thickness(20, Device.OnPlatform(40, 20, 20), 20, 20),
            };

            Button start = new Button
            {
                Text = "Iniciar juego",
                TextColor = Color.White,
                BackgroundColor = Color.Green,
            };

            start.Clicked += delegate
            {
                App.Navigation.PushAsync(new GamePage(nivel, this.Width));
            };

            panel.Children.Add(new Label
            {
                Text = "Dificultad",
                TextColor = Color.Black,
            });

            var dificultad = new Picker
            {
                Title = "Dificultad",
            };
            dificultad.Items.Add("Fácil");
            dificultad.Items.Add("Normal");
            dificultad.SelectedIndex = 0;
            dificultad.SelectedIndexChanged += (sender, args) =>
            {
                nivel = dificultad.SelectedIndex;
            };

            panel.Children.Add(dificultad);
            panel.Children.Add(start);

            panel.Children.Add(new Label
            {
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                Text = "\n\n\nMemorama versión 1.0.0\nRafaelcNet 2014",
                Font = Font.SystemFontOfSize(18),
                TextColor = Color.Black,
            });

            Content = panel;

        }
開發者ID:palaniakasapu,項目名稱:Xamarin,代碼行數:58,代碼來源:Settings.cs

示例15: GetSelectedItemPositionPicker

        public static StackLayout GetSelectedItemPositionPicker(FlexPie chart)
        {
            StackLayout stack = new StackLayout();

            stack.Orientation = StackOrientation.Horizontal;

            Label label = new Label();

            label.Text = "Selected Item Position";

            Picker picker = new Picker();

            picker.VerticalOptions = LayoutOptions.FillAndExpand;
            picker.HorizontalOptions = LayoutOptions.FillAndExpand;
            picker.Title = "Selected Item Position";

            picker.Items.Add("None");
            picker.Items.Add("Left");
            picker.Items.Add("Top");
            picker.Items.Add("Right");
            picker.Items.Add("Bottom");

            picker.SelectedIndex = 2;

            picker.SelectedIndexChanged += (e, sender) =>
            {
                Picker sentPicker = (Picker)e;

                ChartPositionType legendPoistion = ChartPositionType.Bottom;

                switch (sentPicker.SelectedIndex)
                {
                    case 0:
                        legendPoistion = ChartPositionType.None;
                        break;
                    case 1:
                        legendPoistion = ChartPositionType.Left;
                        break;
                    case 2:
                        legendPoistion = ChartPositionType.Top;
                        break;
                    case 3:
                        legendPoistion = ChartPositionType.Right;
                        break;
                    case 4:
                        legendPoistion = ChartPositionType.Bottom;
                        break;
                }

                chart.SelectedItemPosition = legendPoistion;
            };

            stack.Children.Add(label);
            stack.Children.Add(picker);

            return stack;

        }
開發者ID:techShubham,項目名稱:Xamarin.Forms-Samples,代碼行數:58,代碼來源:Pickers.cs


注:本文中的Xamarin.Forms.Picker類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。