Using XmlDataProvider : XmlDataProvider « Windows Presentation Foundation « C# / C Sharp






Using XmlDataProvider

Using XmlDataProvider
    

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      HorizontalAlignment="Center" VerticalAlignment="Center">
    <Grid HorizontalAlignment="Center" VerticalAlignment="Center">
      <Grid.Resources>
        <XmlDataProvider x:Key="myXml" XPath="/Root">
          <x:XData>
            <Root xmlns="">
              <Item id="A" flag="True" value="A" />
              <Item id="B" flag="True" value="B" />
              <Item id="C" flag="False" value="C" />
              <Item id="D" flag="True" value="D" />
            </Root>
          </x:XData>
        </XmlDataProvider>
      </Grid.Resources>
      <ListView DataContext="{StaticResource myXml}" ItemsSource="{Binding XPath=Item}">
        <ListView.View>
          <GridView>
            <GridViewColumn Header="ID" DisplayMemberBinding="{Binding XPath=@id}" />
            <GridViewColumn Header="Enabled">
              <GridViewColumn.CellTemplate>
                <DataTemplate>
                  <CheckBox IsChecked="{Binding XPath=@flag}" />
                </DataTemplate>
              </GridViewColumn.CellTemplate>
            </GridViewColumn>
            <GridViewColumn Header="Value">
              <GridViewColumn.CellTemplate>
                <DataTemplate>
                  <TextBox Text="{Binding XPath=@value}" Width="70" />
                </DataTemplate>
              </GridViewColumn.CellTemplate>
            </GridViewColumn>
          </GridView>
        </ListView.View>
      </ListView>
    </Grid>
</Page>

   
    
    
    
  








Related examples in the same category

1.HierarchicalDataTemplate and XmlDataProviderHierarchicalDataTemplate and XmlDataProvider
2.Xmldata island.xamlXmldata island.xaml
3.Hierarchical Xml TemplatesHierarchical Xml Templates
4.XmlDataProvider and static Xml resourceXmlDataProvider and static Xml resource
5.Retrieve data from XmlDataProvider with XPathRetrieve data from XmlDataProvider with XPath
6.XmlDataProvider and XmlNamespaceMappingXmlDataProvider and XmlNamespaceMapping
7.XmlDataProvider and ItemsControlXmlDataProvider and ItemsControl
8.Hyperlink and xpath filter for XmlDataProviderHyperlink and xpath filter for XmlDataProvider
9.Load XmlDocument to XmlDataProviderLoad XmlDocument to XmlDataProvider
10.Get XmlElement from Bounded viewGet XmlElement from Bounded view