private void dragOver(DragEventArgs e) { IDataObject dataObject = e.Data; if (dataObject == null) { return; } var data = dataObject.GetData(typeof(DraggableRowsBehavior.Data)) as DraggableRowsBehavior.Data; if (data == null) { return; } var lbItem = VisualHelpers.FindAncestor <ListBoxItem>(e.OriginalSource); if (lbItem != null) { lbItem.IsSelected = true; } // add appropriate device for mappings, if file is empty if (!Devices.Any()) { var copy = (data.SenderDataContext as DeviceViewModel).Copy(false); addDevice(copy); SelectedDevice = Devices.First(); } }
public override bool IsValidDropTarget(DependencyObject control) { if (getRow(control) != null) { return(true); } // allow drop on empty selector var grid = VisualHelpers.FindAncestor <DataGrid>(control); if (grid != null && !grid.HasItems) { return(true); } return(false); }
public override bool IsValidDropTarget(DependencyObject control) { if (getListBoxItem(control) != null) { return(true); } // allow drop on empty selector var listbox = VisualHelpers.FindAncestor <ListBox>(control); if (listbox != null && !listbox.HasItems) { return(true); } return(false); }
private DataGridRow getRow(DependencyObject control) { return(VisualHelpers.FindAncestor <DataGridRow>(control)); }
private ListBoxItem getListBoxItem(DependencyObject control) { return(VisualHelpers.FindAncestor <ListBoxItem>(control)); }