protected override void DropStart(object sender, DragEventArgs e) { var target = e.OriginalSource as DependencyObject; var files = e.Data.GetData(DataFormats.FileDrop) as string[]; var fromHelper = e.Data.GetData(AdditionalKey) != null; if (files?.Length > 0 && !fromHelper && Utils.FindParentOfTypes(target, fileDropTargets) is FrameworkElement parent) { var args = new UiFileDropArgs { Files = files.ToList(), Element = parent, Target = parent.DataContext }; CallOnDropChain(args); } }
private void CallOnDropChain(UiFileDropArgs args) { args.Handled = false; OnFileDrop?.Invoke(args); if (args.Handled) { return; } if (args.Element.DataContext is IFileDragDropAware parentAware) { parentAware.OnFilesDrop(args); if (args.Handled) { return; } } if (args.Element != containerElement && containerElement.DataContext is IFileDragDropAware elementAware) { elementAware.OnFilesDrop(args); } }