DataGrid 拖放降低
我有一个带有 DataGrid 的 WPF 对话框。我想要做的是将文件或文件夹拖放到数据网格上并显示信息。每一行代表每个文件。对于我的一生,我无法弄清楚如何插入数据并显示行。
这是掉落代码...
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???
}
}
}
}
I have a WPF dialog with a DataGrid on it. What I want to do is be able to drop a file or folder onto the Datagrid and have the information show up. Each row will represent each file. For the life of me I can't figure out how to insert the data and have the rows show up.
Here is the drop code...
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???
}
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须修改 xaml 才能使事情看起来正确。
You'll have to mess around with the xaml to get things to look right.