Xamarin.Forms.Core
1.0.0.0
1.1.0.0
1.2.0.0
1.3.0.0
1.4.0.0
1.5.0.0
2.0.0.0
Xamarin.Forms.View
Xamarin.Forms.IElementConfiguration<Xamarin.Forms.Picker>
Xamarin.Forms.RenderWith(typeof(Xamarin.Forms.Platform._PickerRenderer))
A control for picking an element in a list.
The visual representation of a Picker is similar to a , but a picker control appears in place of a keyboard.
The following example shows the creation of a Picker.
nameToColor = new Dictionary
{
{ "Aqua", Color.Aqua }, { "Black", Color.Black },
{ "Blue", Color.Blue }, { "Fucshia", Color.Fucshia },
{ "Gray", Color.Gray }, { "Green", Color.Green },
{ "Lime", Color.Lime }, { "Maroon", Color.Maroon },
{ "Navy", Color.Navy }, { "Olive", Color.Olive },
{ "Purple", Color.Purple }, { "Red", Color.Red },
{ "Silver", Color.Silver }, { "Teal", Color.Teal },
{ "White", Color.White }, { "Yellow", Color.Yellow }
};
public PickerDemoPage()
{
Label header = new Label
{
Text = "Picker",
FontSize = Device.GetNamedSize (NamedSize.Large, typeof(Label)),
HorizontalOptions = LayoutOptions.Center
};
Picker picker = new Picker
{
Title = "Color",
VerticalOptions = LayoutOptions.CenterAndExpand
};
foreach (string colorName in nameToColor.Keys)
{
picker.Items.Add(colorName);
}
// Create BoxView for displaying picked Color
BoxView boxView = new BoxView
{
WidthRequest = 150,
HeightRequest = 150,
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.CenterAndExpand
};
picker.SelectedIndexChanged += (sender, args) =>
{
if (picker.SelectedIndex == -1)
{
boxView.Color = Color.Default;
}
else
{
string colorName = picker.Items[picker.SelectedIndex];
boxView.Color = nameToColor[colorName];
}
};
// Accomodate iPhone status bar.
this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);
// Build the page.
this.Content = new StackLayout
{
Children =
{
header,
picker,
boxView
}
};
}
}
}
]]>
XAML for Xamarin.Forms supports the following properties for the class:
Property
Value
-
Items
A list of items with which to populate the picker.
-
SelectedIndex
An integer from 0 to 1 less than the count of items that are listed in Items. This element must be specified in a tag that appears lexically after Items.
-
Title
Text that represents the title of the picker.
Constructor
1.0.0.0
1.1.0.0
1.2.0.0
1.3.0.0
1.4.0.0
1.5.0.0
2.0.0.0
Initializes a new instance of the Picker class.
Property
2.0.0.0
Xamarin.Forms.BindingBase
Gets or sets a binding that selects the property that will be displayed for each object in the list of items.
To be added.
To be added.
Property
1.0.0.0
1.1.0.0
1.2.0.0
1.3.0.0
1.4.0.0
1.5.0.0
2.0.0.0
System.Collections.Generic.IList<System.String>
Gets the list of choices.
An IList<string> representing the Picker choices.
This property is read-only, but exposes the IList<> interface, so items can be added using Add().
Property
2.0.0.0
System.Collections.IList
Gets or sets the source list of items to template and display.
To be added.
To be added.
Field
2.0.0.0
Xamarin.Forms.BindableProperty
Backing store for the property.
To be added.
Method
2.0.0.0
Xamarin.Forms.IPlatformElementConfiguration<T,Xamarin.Forms.Picker>
Xamarin.Forms.IConfigPlatform
To be added.
Returns the platform-specific instance of this , on which a platform-specific method may be called.
To be added.
To be added.
Property
1.0.0.0
1.1.0.0
1.2.0.0
1.3.0.0
1.4.0.0
1.5.0.0
2.0.0.0
System.Int32
Gets or sets the index of the selected item of the picker. This is a bindable property.
An 0-based index representing the selected item in the list. Default is -1.
A value of -1 represents no item selected.
Event
1.0.0.0
1.1.0.0
1.2.0.0
1.3.0.0
1.4.0.0
1.5.0.0
2.0.0.0
System.EventHandler
Raised when the value of the SelectIndex property has changed.
To be added.
Field
1.0.0.0
1.1.0.0
1.2.0.0
1.3.0.0
1.4.0.0
1.5.0.0
2.0.0.0
Xamarin.Forms.BindableProperty
Identifies the SelectedIndex bindable property.
Property
2.0.0.0
System.Object
Gets or sets the selected item.
To be added.
To be added.
Field
2.0.0.0
Xamarin.Forms.BindableProperty
Backing store for the property.
To be added.
Property
2.0.0.0
Xamarin.Forms.Color
Gets or sets the text color.
To be added.
To be added.
Field
2.0.0.0
Xamarin.Forms.BindableProperty
Backing store for the property.
To be added.
Property
1.0.0.0
1.1.0.0
1.2.0.0
1.3.0.0
1.4.0.0
1.5.0.0
2.0.0.0
System.String
Gets or sets the title for the Picker. This is a bindable property.
A string.
Depending on the platform, the Title is shown as a placeholder, headline, or not showed at all.
Field
1.0.0.0
1.1.0.0
1.2.0.0
1.3.0.0
1.4.0.0
1.5.0.0
2.0.0.0
Xamarin.Forms.BindableProperty
Identifies the Title bindable property.