Mega Code Archive

 
Categories / C# / WPF
 

Xmldata island xaml

<Window x:Class="ControlDemos.xmldataisland"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     Title="ControlDemos" Height="300" Width="300">   <Window.Resources>     <XmlDataProvider x:Key="MyCompany" XPath="/Company/Country">       <x:XData>         <Company xmlns="">           <Country Name="USA">             <Employee>A</Employee>           </Country>           <Country Name="England">             <Employee>B</Employee>           </Country>           <Country Name="Japan">             <Employee>C</Employee>           </Country>         </Company>       </x:XData>     </XmlDataProvider>   </Window.Resources>   <Grid>     <StackPanel>       <ListBox>         <ListBox.ItemsSource>           <Binding Source="{StaticResource MyCompany}" XPath="/Company/Country"/>         </ListBox.ItemsSource>         <ListBox.ItemTemplate>           <DataTemplate>             <StackPanel>               <TextBlock>                 <TextBlock.Text>                   <Binding XPath="Employee"/>                 </TextBlock.Text>               </TextBlock>               <TextBlock>                 <TextBlock.Text>                   <Binding XPath="@Name"/>                 </TextBlock.Text>               </TextBlock>             </StackPanel>           </DataTemplate>         </ListBox.ItemTemplate>       </ListBox>     </StackPanel>   </Grid> </Window>