i am trying to display the content in the xml file that i have. this is the code that i have most of it from the documentation.
vb.net code
Imports Infragistics.Windows.DataPresenterClass Window1 Private xamDataGrid1 As XamDataGrid Private Sub Window1_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded xamDataGrid1 = New XamDataGrid() 'You can data bind your instance of xamDataGrid instead of using the built in sample data xamDataGrid1.BindToSampleData = False Me.layoutRoot.Children.Add(xamDataGrid1) End SubEnd Class
XAML Code
<Window x:Class="Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300" xmlns:igDP="http://infragistics.com/DataPresenter"> <Grid Name="layoutRoot"> <Grid.Resources> <XmlDataProvider x:Key="InventoryData" XPath="Inventory/Books"> </XmlDataProvider> </Grid.Resources> <igDP:XamDataGrid DataSource="{Binding Source={StaticResource InventoryData}, XPath=/Data/books.xml}" Height="11" HorizontalAlignment="Left" Margin="10,10,0,0" Name="XamDataGrid2" VerticalAlignment="Top" Width="1" /> </Grid></Window>
when i run the program nothing happens. where and how to i get the grid to display the content of the xml file
thank you
Hello,
Here is a working link for the XML:
http://help.infragistics.com/NetAdvantage/WPF/2012.1/CLR4.0/?page=xamDataPresenter_Bind_a_DataPresenter_Control_to_an_XmlDataProvider.html
to be more clear, the link to the xml article is dead.
thanks.
hey this link is dead. can you relink it?
I believe XmlDataProvider is primarily intended for one way databinding (read only -- from provider to UI component). While it is technically possible to have two-way databinding with XmlDataProvider as mentioned in this article:
http://www.codeproject.com/KB/WPF/WpfXml2WayDataBinding.aspx?display=PrintAll
it might prove a bit tricky and not possible in all cases (still, you can certainly try that of course).
Another way to go would be to simply load the XML into DataSet using ReadXml and then write it back to a file using WriteXml
http://msdn.microsoft.com/en-us/library/system.data.dataset.readxml.aspx
HTH,
thanks for the quick reply it seems that i do not need the vb code at all and myXMLDataProvider was all sorts of screwed up.
The online documentation was a little wierd and gave me what seems to be wrong information but the link that you sent me too worked and explained it great.
So now for my next question if i wanted to edit the fields in the xamDataGrid and then update the xml file is there a way to do this in xamDataGrid or would I have to do that in code and if you could link to or show an example that would be great
Thank You again