C# 通过ItemsSource向WPF datagridview添加内容

C# 通过ItemsSource向WPF datagridview添加内容,c#,C#,我是这样读xml文件的 string appDataPath1 = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); string configPath1 = appDataPath1 + "/LWRF/ReaderProfiles"; string fn = System.IO.Path.Combine(configPath1 + ComboBoxProfiles.Text);

我是这样读xml文件的

    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文件内容显示在gridview中?我已将此代码添加到
组合框\u SelectionChanged
事件中,但即使在选择更改后,我的datagridview仍为空。

很可能您在configPath1中缺少一个
/

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

\u currentProfile.DefaultView
中是否有任何数据?是的,其中有数据。感谢您回复sa_ddam213!阿比,你完全正确。一旦我实现了你的想法,它就非常有效,并且完美地填充了dataviewgrid!非常感谢,萨罗