Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

xamarin picker item

// replacement text "Pick the artistic filter"
<Picker Title="Pick the artistic filter" x:Name="picker">
        <Picker.Items>
               <x:String>udnie</x:String>
               <x:String>wave</x:String>
               <x:String>la_muse</x:String>
               <x:String>rain_princess</x:String>
         </Picker.Items>
</Picker>
Comment

xamarin picker

<Picker 
   Title="What Type of User Are You?" 
   x:Name="txtUserType"  
   Style="{StaticResource DeafultPicker}"
   SelectedIndexChanged="txtUserType_SelectedIndexChanged"
>
	<Picker.ItemsSource>
     	<x:Array Type="{x:Type x:String}">
     		<x:String>Human</x:String>
            <x:String>Robot</x:String>
		</x:Array>
	</Picker.ItemsSource>
</Picker>
Comment

xamarin picker item


class PickerDemoPage : ContentPage
        {
            // Dictionary to get Color from color name.
            Dictionary<string, Color> nameToColor = new Dictionary<string, Color>
            {
                { "Aqua", Color.Aqua }, { "Black", Color.Black },
                { "Blue", Color.Blue }, { "Fuschia", Color.Fuschia },
                { "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
                    }
                };

            }
        }

Comment

PREVIOUS NEXT
Code Example
Csharp ::  
Csharp ::  
:: unity invisible cube 
::  
:: how to find avareage of an array in c# 
Csharp ::  
:: how to get the time since play unity 
::  
::  
Csharp ::  
:: oncollisionenter 
Csharp :: shorthand in c# operator 
::  
:: c# convert enum to list 
Csharp ::  
Csharp :: unity 2d looka tt mouse 
::  
::  
Csharp :: how to ping in c# forms 
::  
Csharp ::  
::  
::  
::  
:: video gets pixelated unity 
::  
::  
Csharp :: c# loop through files in folder 
::  
::  
ADD CONTENT
Topic
Content
Source link
Name
8+2 =