我有一个带有DataGrid的WPF对话框。我想要做的是能够将文件或文件夹放到Datagrid上并显示信息。每行代表每个文件。对于我的生活,我无法弄清楚如何插入数据并显示行。
这是丢弃代码......
public partial class SplitWindow : UserControl
{
public SplitWindow()
{
this.InitializeComponent();
}
private void FilesDropped(object sender, System.Windows.DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
DropDataGrid.Items.Clear();
string[] droppedFilePaths = e.Data.GetData(DataFormats.FileDrop, true) as string[];
foreach (string droppedFilePath in droppedFilePaths)
{
string name = System.IO.Path.GetFileNameWithoutExtension(droppedFilePath);
// insert row???
}
}
}
}
答案 0 :(得分:1)
你必须弄乱xaml以使事情看起来正确。