Hi,
ComboBox.ItemsSource is supposed to work fine.
Here is an example of use:
Code: Select all
<StackPanel>
<ComboBox x:Name="ComboBox1" DisplayMemberPath="Name"/>
<TextBlock Text="Selected planet radius:"/>
<TextBlock Text="{Binding ElementName=ComboBox1, Path=SelectedItem.Radius}"/>
</StackPanel>
Code: Select all
class Planet
{
public string Name { get; set; }
public string Radius { get; set; }
public string RotationPeriod { get; set; }
public string OrbitalPeriod { get; set; }
public string ImagePath { get; set; }
}
Code: Select all
var planets = new ObservableCollection<Planet>()
{
new Planet() { Name = "Mercury", Radius = "2,400 km", RotationPeriod = "59 days", OrbitalPeriod = "3 months", ImagePath = "ms-appx:/Planets/Mercury.png" },
new Planet() { Name = "Venus", Radius = "6,100 km", RotationPeriod = "243 days", OrbitalPeriod = "7 months", ImagePath = "ms-appx:/Planets/Venus.png" },
new Planet() { Name = "Earth", Radius = "6,400 km", RotationPeriod = "1 day", OrbitalPeriod = "1 year", ImagePath = "ms-appx:/Planets/Earth.png" },
new Planet() { Name = "Mars", Radius = "3,400 km", RotationPeriod = "1 day, 37 min", OrbitalPeriod = "2 years", ImagePath = "ms-appx:/Planets/Mars.png" },
new Planet() { Name = "Jupiter", Radius = "71,500 km", RotationPeriod = "1 day, 10 hrs", OrbitalPeriod = "12 years", ImagePath = "ms-appx:/Planets/Jupiter.png" },
new Planet() { Name = "Saturn", Radius = "60,300 km", RotationPeriod = "1 day, 11 hrs", OrbitalPeriod = "30 years", ImagePath = "ms-appx:/Planets/Saturn.png" },
new Planet() { Name = "Uranus", Radius = "25,600 km", RotationPeriod = "1 day, 17 hrs", OrbitalPeriod = "84 years", ImagePath = "ms-appx:/Planets/Uranus.png" },
new Planet() { Name = "Neptune", Radius = "24,800 km", RotationPeriod = "1 day, 16 hrs", OrbitalPeriod = "165 years", ImagePath = "ms-appx:/Planets/Neptune.png" },
};
ComboBox1.ItemsSource = planets;
In the current Beta 7.2, the combo box uses the native HTML5 control, so it can only display simple values. However, the "ItemsSource" collection can contain complex objects. You can tell the ComboBox which value to display by setting the "DisplayMemberPath" property of the ComboBox, as shown in the example above.
Regards,
JS-Support