xamarin.android - Create a custom Spinner -


i trying customize mvxspinner add additional controls, here code:

public class chamspinner : linearlayout {     public spinner spinner{ get; private set; }      public eventhandler<adapterview.itemselectedeventargs> itemselected;      public chamspinner (context context, iattributeset attrs) : (context, attrs, new chamspinneradapter (context))     {      }      public chamspinner (context context, iattributeset attrs, imvxadapter adapter) : base (context, attrs)     {         ((activity)context).layoutinflater.inflate (resource.layout.chamspinnerlayout, this);         spinner = findviewbyid<spinner> (resource.id.chamspinnerspinner);         int itemtemplateid = mvxattributehelpers.readlistitemtemplateid (context, attrs);         int dropdownitemtemplateid = mvxattributehelpers.readdropdownlistitemtemplateid (context, attrs);         adapter.itemtemplateid = itemtemplateid;         adapter.dropdownitemtemplateid = dropdownitemtemplateid;         adapter = adapter;         setuphandleitemselected ();     }      public new imvxadapter adapter     {         { return spinner.adapter imvxadapter; }         set         {             var existing = adapter;             if (existing == value)                 return;              if (existing != null && value != null)             {                 value.itemssource = existing.itemssource;                 value.itemtemplateid = existing.itemtemplateid;             }              spinner.adapter = value;         }     }      [mvxsettonullafterbinding]     public ienumerable itemssource     {                 {             return adapter.itemssource;         }         set         {             adapter.itemssource = value;         }     }      public int itemtemplateid     {         { return adapter.itemtemplateid; }         set { adapter.itemtemplateid = value; }     }      public int dropdownitemtemplateid     {         { return adapter.dropdownitemtemplateid; }         set { adapter.dropdownitemtemplateid = value; }     }      public icommand handleitemselected { get; set; }      private void setuphandleitemselected ()     {         spinner.itemselected += (sender, args) =>         {             var position = args.position;             handleselected (position);             if (itemselected != null)                 itemselected (sender, args);         };     }      protected virtual void handleselected (int position)     {         var item = adapter.getrawitem (position);         if (this.handleitemselected == null             || item == null             || !this.handleitemselected.canexecute (item))             return;          this.handleitemselected.execute (item);      } } 

and using this:

<cross.android.chamspinner         android:layout_width="fill_parent"         android:layout_height="wrap_content"         local:mvxdropdownitemtemplate="@layout/myspinneritemdropdown"         local:mvxitemtemplate="@layout/myspinneritem"         local:mvxbind="itemssource myitemssource; selecteditem myitem; mode twoway" /> 

the spinner empty, tried add custom binding on itemssource property result stilll same. how can show items in spinner?

thank in advance.

i think using bindinginflate instead of inflate should fix or points in right direction. https://github.com/mvvmcross/mvvmcross/blob/v3.1/cirrious/cirrious.mvvmcross.binding.droid/bindingcontext/imvxandroidbindingcontext.cs

((imvxbindingcontextowner)context).bindinginflate(resource.layout.chamspinnerlayout, this); 

Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -