PSC.Xamarin.Controls.BindablePicker (component)

Nuget Package

BindablePicker for Xamarin Forms

This BindablePicker is the result of studying blog and forum posts. I'm using this component in more than 2000 views and 700 users. I think my component is stable.

Download it from NuGet.

What's included?

A bindable picker component.

Example

In your XAML

Add at the top of your page the following code:

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:psc="clr-namespace:PSC.Xamarin.Controls.BindablePicker;
                        assembly=PSC.Xamarin.Controls.BindablePicker">

Add a bindable picker in your form:

<psc:BindablePicker ItemsSource="{Binding UtilityTypeList}" 
                    SelectedItem="{Binding SelectedUtility}" 
                    DisplayProperty="Description" />

In your ViewModel

		private List<Data.UtilityType> _utilityTypeList;
		/// <summary>
		/// Gets or sets the utility type list.
		/// </summary>
		/// <value>The utility type list.
		public List<Data.UtilityType> UtilityTypeList
		{
			get
			{
				return _utilityTypeList;
			}
			set
			{
				_utilityTypeList = value;
				OnPropertyChanged("UtilityTypeList");
			}
		}

		private int _selectedUtilityId;
		public int SelectedUtilityId
		{
			get
			{
				return _selectedUtilityId;
			}
			set
			{
				_selectedUtilityId = value;
				OnPropertyChanged("SelectedUtilityId");
			}
		}

		private Data.UtilityType _selectedUtility = null;
		/// <summary>
		/// Gets or sets the selected utility.
		/// </summary>
		/// <value>The selected utility.
		public Data.UtilityType SelectedUtility
		{
			get
			{
				return _selectedUtility;
			}
			set
			{
				_selectedUtility = value;
				if (_selectedUtility != null)
				{
					SelectedUtilityId = value.Id;
				}
				OnPropertyChanged("SelectedUtility");
			}
		}

iOS

You must add in your AppDelegate.cs the initialisation for this component like. Add the following code:

public override bool FinishedLaunching(UIApplication app, 
                                       NSDictionary options)
{
    global::Xamarin.Forms.Forms.Init();

    // initialize my components
    // this is a work around only for iOS. If you don't do that, you received an error like 
    // System.IO.FileNotFoundException
    BindablePicker temporary = new BindablePicker();

    ...

}

Advertsing

125X125_06

Planet Xamarin

Planet Xamarin

Calendar

<<  November 2017  >>
MonTueWedThuFriSatSun
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

View posts in large calendar

Month List