2013-02-16 26 views
0

我讀像這樣通過添加內容的ItemsSource到WPF的datagridview

string appDataPath1 = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); 
    string configPath1 = appDataPath1 + "/LWRF/ReaderProfiles"; 
    string fn = System.IO.Path.Combine(configPath1 + ComboBoxProfiles.Text); 
     _currentProfile.Clear(); 
     try 
     { 
      Log("Loading profile: " + fn); 
      _currentProfile.ReadXml(fn); 
      _dgvProfile.ItemsSource = _currentProfile.DefaultView; 
     } 
     catch 
     { 

     } 

一個XML文件,我需要做的,使XML文件內容在GridView顯示什麼呢?我將這段代碼添加到ComboBox_SelectionChanged事件中,但即使在選擇更改後,我的datagridview也是空白的。

+0

有在'_currentProfile.DefaultView'的數據? – 2013-02-16 21:59:48

+0

是的,裏面有數據。感謝您回覆sa_ddam213! – 2013-02-18 03:27:28

回答

0

最可能的是你缺少在configPath1一個/

string configPath1 = appDataPath1 + "/LWRF/ReaderProfiles/"; 
+0

AbZy你完全正確。一旦我實現了你的想法,它的工作很好,並完美填充dataviewgrid!非常感謝,saroj – 2013-02-18 03:28:22

+0

@JoJoAndChickie很高興聽到,你可以標記這個答案爲接受。 – AbZy 2013-02-18 09:45:05