c# - Bind a List<Group> to ComboBox? -


i have following xaml:

<combobox   name="groupcombobox"   itemssource="{binding path=myservicemap.groups}"  displaymemberpath="{binding name}"/> 

in code behind set this.datacontext viewmodel.

private servicemap _servicemap;     public servicemap myservicemap     {                 {             return _servicemap;         }         set         {             _servicemap = value;             onpropertychanged("myservicemap");         }     } 

my servicemap class is

public class servicemap {     //other code     public list<group> groups = new list<group>(); } 

and finally:

public class group {     public string name { get; set; } } 

unfortunately, not working. how can bind combobox show group name?

there 2 problems code. first bindings work on properties, binding couldn't find group field. change property.

public class servicemap {     public list<group> groups { get; set; } } 

the second 1 displaymemberpath waits string not binding. change "name".

<combobox name="groupcombobox"     itemssource="{binding path=myservicemap.groups}"     displaymemberpath="name" /> 

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -