c# - What is the alternative for DisplayMemberPath="Value" for Windows Store applications? -


i think there bug windows store applications when comes using displaymemberpath="value".

here code

    <combobox height="40" verticalalignment="stretch" selectedvaluepath="key" displaymemberpath="value" x:name="combobox1" fontsize="25"/>  var source = new dictionary<string, double>();             source.add("item1", 0.4);             source.add("item2", 0.3);             source.add("item3", 0.1);             source.add("item4", 0.1);              var formatedsource = new dictionary<string, string>();              foreach (var item in source)             {                 formatedsource.add(string.format("[{0}, {1}]", item.key, item.value), item.key);             }              combobox1.itemssource = source; 

if use code in wpf in works perfectly. if use code in windows store application combo box empty , error thrown. there alternative way in windows store applications , have unearthed bug? because have researched web days , found no solution this.*please not comment unless have tried code windows store app not wpf in visual studios.

i've been able reproduce in universal app (windows phone version).

to solve it, first remove "height" property value on combobox, because prevent combobox show options when open (on windows phone @ least).

then, in code behind, try converting dictionnary list (or dictionnary) of objects (i used anonymous objects, better create custom type) :

combobox1.itemssource = formatedsource.select(f => new { key = f.key, value = f.value }).tolist(); 

so xaml looks :

<combobox x:name="combobox1"               verticalalignment="stretch"               displaymemberpath="value"               fontsize="25"               selectedvaluepath="key" /> 

right now, don't understand what's going on raw dictionnary, @ least should have workaround now.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -