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

Find correct current adorner layer (root element) #165

Merged
merged 2 commits into from
Aug 4, 2016

Conversation

starguy
Copy link

@starguy starguy commented Feb 8, 2016

Signed-off-by: Rico-E reissmann@advitec.de

Signed-off-by: Rico-E <reissmann@advitec.de>
@punker76
Copy link
Owner

@starguy hi, thx for the contribution, but

  • please add the <Compile Include="Utilities\RootElementFinder.cs" /> to GongSolutions.Wpf.DragDrop (NET4).csproj too
  • can you explain a little bit more what exactly was the cause?

thx

Signed-off-by: Rico-E <reissmann@advitec.de>
@starguy
Copy link
Author

starguy commented Feb 10, 2016

@punker76 hi, I just added the RootElementFinder to the NET4 project.
I've created this class, because you were looking for the root element at two different positions. First to create the DragAdorner, and secondly to create the DragEffectAdorner. These two positions diverged, especially the root element for the DragEffectAdorner was not correct for a dialog window. So I refactored it, to use the RootElementFinder which finds the correct elemnt even in a dialog window.

@punker76
Copy link
Owner

@starguy 🆒 this makes sense, just onyl short note

in

var rootElement = RootElementFinder.FindRoot(m_DragInfo.VisualSource);
//                i don't want the fu... windows forms reference
//                if (rootElement == null) {
//                    var elementHost = m_DragInfo.VisualSource.GetVisualAncestor<ElementHost>();
//                    rootElement = elementHost != null ? elementHost.Child : null;
//                }
if (rootElement == null) {
    rootElement = m_DragInfo.VisualSource.GetVisualAncestor<UserControl>();
}

i think we can put this in the new FindRoot method too

if (rootElement == null) {
    rootElement = m_DragInfo.VisualSource.GetVisualAncestor<UserControl>();
}

@punker76 punker76 added this to the v1.0.0 milestone Feb 10, 2016
@starguy
Copy link
Author

starguy commented Feb 10, 2016

@punker76 Yes, indeed. I think that would be usefull for forms, when the content of the host is an UserControl.

@punker76 punker76 merged commit 091a390 into punker76:master Aug 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants