MSDN > 論壇首頁 > Windows Presentation Foundation (WPF) > From datatable to xaml table document
發問發問
 

已答覆From datatable to xaml table document

解答

  • Friday, 3 July, 2009 15:12Kenneth Haugland 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     已答覆
    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

所有回覆

  • Friday, 3 July, 2009 9:41Myexp 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    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
  • Friday, 3 July, 2009 13:38marck68 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    well actually i was expecting to get the table directly from the datatable
  • Friday, 3 July, 2009 15:12Kenneth Haugland 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     已答覆
    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
  • Friday, 3 July, 2009 21:14marck68 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    xaml table
  • Friday, 3 July, 2009 23:40Kenneth Haugland 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    dim  ds as new dsystem.data.dataset
    ds.ReadXML(filename)

    and you will have the datatable.... if its from a file
    Kenneth
  • Saturday, 4 July, 2009 3:38Myexp 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    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 Table
    You want some method to generate xaml code for the DataTable? That is not supported. 

    Experience
  • Thursday, 9 July, 2009 9:43Jim Zhou - MSFT版主使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     

    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.

  • Thursday, 9 July, 2009 9:48Kenneth Haugland 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    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