Adding key values for items in picker

前端 未结 3 1967
借酒劲吻你
借酒劲吻你 2021-02-07 12:34

I am using a XAMARIN picker to select a country. The countries are hard coded in the picker. Is there a way I could identify each country name through a key value. I have done t

3条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-07 12:46

    I was just facing the same problem and I found a way to do it. I just needed to bind a picker with a list of SomeClass elements. Here is what I did:

    namespace MyApp.ViewModels 
    {
        public class CboViewModel 
        {
            public int Id { get; set; }
            public string Name { get; set; }
        }
    }
    

    And then in my XAML file:

    
        
            ...
            
                
                    
                        
                        
                        
                        
                        
                        
                    
                
                
                    
                
                0
            
            ...
        
    
    

提交回复
热议问题