silverlight - Binding Dictionary<string,string> to Combobox in SL3 -
i'm trying following. have class:
public class textfield { public string texttype { get; set; } }
in view created list:
public textfieldeditcontrol() { initializecomponent(); dictionary<string, string> lst = new dictionary<string, string>(); lst.add("singleline", "single line"); lst.add("multiline", "multi-line"); lst.add("richtext", "rich text"); cmbtexttype.itemssource = lst; }
in xaml have:
<combobox x:name="cmbtexttype" displaymemberpath="value" selectionchanged="cmbtexttype_selectionchanged" selecteditem="{binding path=texttype, mode=twoway}" />
the problem when check value of texttype property, returns string that: "[singleline, single line]" instead of key. can set return key key/value pair?
in title specified silverlight 3, unfortunately didn't have selectedvalue , selectedvaluepath properties anthony mentions. means need nasty workaround work. discuss here in silverlight 2 era article of mine, in section titled "the combobox nightmare": http://www.silverlightshow.net/items/building-a-silverlight-line-of-business-application-part-5.aspx. pain in silverlight 2, , wasn't fixed until silverlight 4.
hope helps...
chris
Comments
Post a Comment