locked
DisplayMemberPath=“Value” for Windows Store applications?

    Question

  •   

    I think there is a bug with Windows Store Applications when it comes to using DisplayMemberPath="Value".

    Here is my 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 you use this code in WPF in works perfectly. However if you use this code in a Windows Store Application then the Combo Box is empty and an error is thrown. So is there an alternative way to do this in Windows Store Applications and have I unearthed a bug? Because I have researched the Web for days and found no solution to this.*please do not comment unless you have tried my code as a Windows Store App not a WPF in Visual Studios. Can Someone post an example based on my code that works in Windows Store Apps please because this is terrible.

    Thanks

    • Moved by CoolDadTx Thursday, April 23, 2015 2:08 PM WinStore related
    Thursday, April 23, 2015 8:33 AM

Answers