.NET Framework Developer Center >
.NET Development Forums
>
Windows Presentation Foundation (WPF)
>
From datatable to xaml table document
From datatable to xaml table document
- Hello
Is there a simple way to convert the content of a datatable in a xaml table?- Edited bymarck68 Friday, July 03, 2009 6:11 AM
Answers
- Hi
I do not understand what you mean... If you a datatable and want to make a XML tabel use WriteXML()
If you have a XML table and want it in a datatable use ReadXML()
well actually i was expecting to get the table directly from the datatable
Get what? The xml tabel?
Kenneth- Marked As Answer byJim Zhou - MSFTModeratorThursday, July 09, 2009 9:49 AM
All Replies
- Hi, Do you want to show the datatable data as table on the window? http://msdn.microsoft.com/en-us/library/ms750416.aspx
You can not expect datatable to generate the code, it can only generate xml code once you call WriteXml method.
Experience - well actually i was expecting to get the table directly from the datatable
- Hi
I do not understand what you mean... If you a datatable and want to make a XML tabel use WriteXML()
If you have a XML table and want it in a datatable use ReadXML()
well actually i was expecting to get the table directly from the datatable
Get what? The xml tabel?
Kenneth- Marked As Answer byJim Zhou - MSFTModeratorThursday, July 09, 2009 9:49 AM
- xaml table
- dim ds as new dsystem.data.dataset
ds.ReadXML(filename)
and you will have the datatable.... if its from a file
Kenneth - marck,
kenneth's post is what I mean, save your data to xml and read from it with ReadXml or WriteXml. But now I confuse with your requirement of XAML TableYou want some method to generate xaml code for the DataTable? That is not supported.
Experience Hi,
I think Kenneth Haugland has provided a good post in your case. As far as in know, there is no direct approach to make conversion from a ADO.NET DataTable to a Table of type Block in WPF. You need to write your own code to wrap DataTable as a Table using TableColumn and TableRow.
If you are still having any issues with this, you can elaborate on you scenario. Some sample code will be much better for others to understand you.
Thanks.
- Edited byJim Zhou - MSFTModeratorThursday, July 09, 2009 9:48 AM
- If you do have a XAML table and want to read it... I suggest you convert it to a txt file and read line by line.... It will be a tremendus task... If you can store and read it as a XML table you will save a lot of trouble....
Kenneth


