When i want to xml data load to the combobox . i got this solution. Its very simple to load the xml data. this the xml data.
<Items> <Item> <ItemId>1</ItemId> <ItemName>Architecting ASP.NET Applications eBook</ItemName> <Price>19.95</Price> </Item> <Item> <ItemId>2</ItemId> <ItemName>Fundamentals of N-Tier eBook</ItemName> <Price>19.95</Price> </Item> ... ... <Item> <ItemId>3</ItemId> <ItemName>Security for ASP.NET Developers eBook</ItemName> <Price>19.95</Price> </Item> </Items>
<StackPanel.Resources> <XmlDataProvider x:Key="ItemsData" Source="/Items.xml" XPath="Items/Item" /> </StackPanel.Resources>
<ComboBox Name="Items" MinWidth="200" Style="{StaticResource RequiredComboBox}" Foreground="Black" FontSize="30" IsSynchronizedWithCurrentItem="False" SelectedIndex="0"> <ComboBox.ItemContainerStyle> <Style TargetType="ComboBoxItem"> <Setter Property="Padding" Value="5"> </Setter> </Style> </ComboBox.ItemContainerStyle> <ComboBox.ItemsSource> <Binding Source="{StaticResource ItemsData}" XPath="ItemName" /> </ComboBox.ItemsSource> </ComboBox>
0 comments
Post a Comment