Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library throws "The specified Visual is not an ancestor of this Visual" #146

Closed
DominikPalo opened this issue Oct 21, 2015 · 2 comments
Closed
Labels
Milestone

Comments

@DominikPalo
Copy link

I'm using your library (version 1.0.0-ALPHA011) for ordering and moving items beetween ListViews and sometimes an exception "The specified Visual is not an ancestor of this Visual" is thrown. It happens randomly (~10-20% of drag&drops).

Update: it happens only with ListView items which contains in their DataTemplate a nested ListView and I start dragging by clicking on the item from a nested ListView (also after item is dropped, an item from dropped item's nested listview is moved out from parent item... but nested ListView has not allowed drag&drop functionaliy -> IsDragSource is set to false and drag adorner shows entire item with nested ListView while dragging)

Stack trace:

   at System.Windows.Media.Visual.TrySimpleTransformToAncestor(Visual ancestor, Boolean inverse, GeneralTransform& generalTransform, Matrix& simpleTransform)
   at System.Windows.Media.Visual.TransformToAncestor(Visual ancestor)
   at GongSolutions.Wpf.DragDrop.Utilities.ItemsControlExtensions.GetClosest(ItemsControl itemsControl, List`1 items, Point position, Orientation searchDirection) in d:\projects\git\gong-wpf-dragdrop\GongSolutions.Wpf.DragDrop\Utilities\ItemsControlExtensions.cs:line 361
   at GongSolutions.Wpf.DragDrop.Utilities.ItemsControlExtensions.GetItemContainerAt(ItemsControl itemsControl, Point position, Orientation searchDirection) in d:\projects\git\gong-wpf-dragdrop\GongSolutions.Wpf.DragDrop\Utilities\ItemsControlExtensions.cs:line 134
   at GongSolutions.Wpf.DragDrop.DropInfo..ctor(Object sender, DragEventArgs e, DragInfo dragInfo) in d:\projects\git\gong-wpf-dragdrop\GongSolutions.Wpf.DragDrop\DropInfo.cs:line 78
   at GongSolutions.Wpf.DragDrop.DragDrop.DropTarget_PreviewDragOver(Object sender, DragEventArgs e) in d:\projects\git\gong-wpf-dragdrop\GongSolutions.Wpf.DragDrop\DragDrop.cs:line 845
   at GongSolutions.Wpf.DragDrop.DragDrop.DropTarget_PreviewDragEnter(Object sender, DragEventArgs e) in d:\projects\git\gong-wpf-dragdrop\GongSolutions.Wpf.DragDrop\DragDrop.cs:line 820
   at System.Windows.DragEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.ContentElement.RaiseEvent(RoutedEventArgs e)
   at System.Windows.OleDropTarget.RaiseDragEvent(RoutedEvent dragEvent, Int32 dragDropKeyStates, Int32& effects, DependencyObject target, Point targetPoint)
   at System.Windows.OleDropTarget.MS.Win32.UnsafeNativeMethods.IOleDropTarget.OleDragOver(Int32 dragDropKeyStates, Int64 point, Int32& effects)
@punker76
Copy link
Owner

@DominikPalo Can you provide some code? What kind of items are hosted in your ListViews? Is there a special template or something else?

@DominikPalo
Copy link
Author

    <DataTemplate DataType="{x:Type vm:MyParentItemModel}">
        <Grid AllowDrop="True">
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
            </Grid.RowDefinitions>
            <Label Grid.Row="0" Content="My label" />
            <!-- This nested ListView contains some items and problem occurs when I start dragging parent item from position in nested ListView OR dragging other item ovet this item -->
            <ListView Grid.Row="1" ItemsSource="{Binding NestedListViewItems}" AllowDrop="False" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled" />
        </Grid>
    </DataTemplate>

This is not my original DataTemplate, but I created this simplified template of item in my ListView for demonstration - it also throws the described exception.

Also other problem is, that I cannot drop item to the empty nested ListView (if a nested ListView contains some items, drop works and item is added)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants