Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8384393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:23:44+00:00 2026-06-09T17:23:44+00:00

I had created a drag and drop control in wpf to drag and drop

  • 0

I had created a drag and drop control in wpf to drag and drop data between two list boxes which worked as a charm until I moved it to another project.

The difference being It was initially a wpf window and used the window object to get the mouse position and the position of the controls inside.

this.topWindow = Window.GetWindow(this.sourceItemsControl); //Source items control is instance of ItemsControl

bool previousAllowDrop = this.topWindow.AllowDrop;
this.topWindow.AllowDrop = true;

and now I had to change it to a user control instead, since its a part of a bigger project which is a Windows forms project and the views are linked as a Smart Part from the main project. So now the Window object is null.

I looked for a similar functionality for User Control but could not find it..What is it that I am missing out?? I know there should be something..Would appreciate any help on the same..

P.S. : I am using the MVVM architecture

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T17:23:46+00:00Added an answer on June 9, 2026 at 5:23 pm

    Found the way to find the base User control using recursion, Thanks to ekholm for the heads up..

    public static UserControl FindParentControl(DependencyObject child)
            {
                DependencyObject parent = VisualTreeHelper.GetParent(child);
    
                //CHeck if this is the end of the tree
                if (parent == null) return null;
    
                UserControl parentControl = parent as UserControl;
                if (parentControl != null)
                {
                    return parentControl;
                }
                else
                {
                    //use recursion until it reaches a Window
                    return FindParentControl(parent);
                }
            } 
    

    Now this base user control can be used to find the coordinates (reference) as well as setting other properties like AllowDrop, DragEnter, DragOver etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had created one div window which is draggable,and created one child div (with
i had created a class with two properties one of datetime datatype and other
I had created a webpage using asp.net mvc3 razor. I have two master pages
I have created a ListView which contains a list of items. Each item in
I've never really had the need to use any drag functions until now, so
I had created a small app such that the image which is displaying should
I had created a DLL in .NET ,which includes several function.Now I am suing
I had created an rails app which is using thin server for starting it
I had created database in my android app, then inserted a statement. Everything worked,
I had created the following view, SELECT currency_cd, SUM(comprate) AS salary, employee_code, (SELECT SUM(c.comprate)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.