Monday, 9 September 2013

First combobox item not displaying

First combobox item not displaying

I have a WPF ComboBox that's databound to an xml document such that the
contents of the xml document are displayed in the ComboBox. The problem is
that the first item always disappears when it's selected (i.e., there's no
text displayed). What's going on, and how do I fix this?
Here's the relavent xaml code:
<Window.Resources>
<XmlNamespaceMappingCollection x:Key="nsMap">
<XmlNamespaceMapping Uri="LEDSimulator.Library" Prefix="l" />
</XmlNamespaceMappingCollection>
<XmlDataProvider x:Key="LEDOptions" Source="LEDLibrary.xml"
XmlNamespaceManager="{StaticResource nsMap}" />
</Window.Resources>
<Grid>
<ComboBox Name="cmbPropertiesLEDSelected" Width="100" Height="23"
ItemsSource="{Binding Source={StaticResource
LEDOptions}, XPath=//l:LEDLibrary/l:LED}"
SelectedValue="{Binding Source={StaticResource
LEDOptions}, XPath=//l:LEDLibrary/l:LED}"
SelectedValuePath="@ID"
DisplayMemberPath="l:ManufacturerPartNumber" />
</Grid>
And here's the relavent portion of the xml code:
<?xml version="1.0" encoding="utf-8" ?>
<LEDLibrary xmlns="LEDSimulator.Library">
<LED ID="0">
<ManufacturerPartNumber>BL-HB335A-TRB</ManufacturerPartNumber>
</LED>
<LED ID="1">
<ManufacturerPartNumber>LTST-C190KFKT</ManufacturerPartNumber>
</LED>
<LED ID="2">
<ManufacturerPartNumber>SML-E12WBC7W1</ManufacturerPartNumber>
</LED>
</LEDLibrary>
Thank you in advance!

No comments:

Post a Comment