本文整理汇总了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 };
}
示例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
}
}
};
}
示例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");
}
示例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
}
}
};
}
示例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);
}
示例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 ();
}
示例7: SetColors
private void SetColors(Picker picker)
{
foreach (var color in Configurations.ColorNames)
{
picker.Items.Add(color);
}
}
示例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
}
};
}
示例9: InitPicker
internal void InitPicker(Picker picker)
{
foreach (string colorName in _nameToColor.Keys)
{
picker.Items.Add(colorName);
}
}
示例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");
}
示例11: CompareSelectedIndex
private bool CompareSelectedIndex(Picker myPicker, string name)
{
if (myPicker.SelectedIndex == -1)
return false;
return myPicker.Items[myPicker.SelectedIndex] == name;
}
示例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");
}
示例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]);
// };
// }
}
示例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;
}
示例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;
}