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 3808502
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T15:09:26+00:00 2026-05-19T15:09:26+00:00

I’m working with WPF 4 and VB.net 2010. My project consists of full-screen windows

  • 0

I’m working with WPF 4 and VB.net 2010. My project consists of full-screen windows with a 640×480 grid in the center.

In this project, I want to have various image boxes (which will have the item .png images in them), that the user can drag around and drop in various places on the grid.

In essence, I need to be able to make it possible for the item to be clicked and dragged around the grid, with the image box still visible and the same size as the user moves it around. It should never be able to leave the grid. I also need to be able to determine if the object is over another object, so when the mouse button is released, the dragged object is “dropped”, and it triggers a particular block of code.

How do I do this?

  • 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-05-19T15:09:27+00:00Added an answer on May 19, 2026 at 3:09 pm

    Something similar to your ‘project’, but using C#

    From http://pastie.org/1498237

    // XAML
    
    <Window x:Class="MyProject.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="500" Width="500">
        <Grid>
            <Canvas x:Name="mycanv">
                <Image Width="150" x:Name="myimg" Source="some_source.png"/>
            </Canvas>
        </Grid>
    </Window>
    
    //C#
    
    private Point mouseClick;
    private double canvasLeft;
    private double canvasTop;
    public Window1()
    {
        InitializeComponent();
        foreach (object obj in mycanv.Children)
        {
            try
            {
                Image img = (Image)obj;
                img.PreviewMouseDown += new MouseButtonEventHandler(myimg_MouseDown);
                img.PreviewMouseMove += new MouseEventHandler(myimg_MouseMove);
                img.PreviewMouseUp += new MouseButtonEventHandler(myimg_MouseUp);
                img.TextInput += new TextCompositionEventHandler(myimg_TextInput);
                img.LostMouseCapture += new MouseEventHandler(myimg_LostMouseCapture);
                img.SetValue(Canvas.LeftProperty, 0.0);
                img.SetValue(Canvas.TopProperty, 0.0);
            }
            catch
            {
                //do something
            }
        }
    }
    
    void myimg_LostMouseCapture(object sender, MouseEventArgs e)
    {
        ((Image)sender).ReleaseMouseCapture();
    }
    
    void myimg_TextInput(object sender, TextCompositionEventArgs e)
    {
        ((Image)sender).ReleaseMouseCapture();
    }
    
    void myimg_MouseUp(object sender, MouseButtonEventArgs e)
    {
        ((Image)sender).ReleaseMouseCapture();
    }
    
    void myimg_MouseMove(object sender, MouseEventArgs e)
    {
        if (((Image)sender).IsMouseCaptured)
        {
            Point mouseCurrent = e.GetPosition(null);
            double Left = mouseCurrent.X - canvasLeft;
            double Top = mouseCurrent.Y - canvasTop;
            ((Image)sender).SetValue(Canvas.LeftProperty, canvasLeft + Left);
            ((Image)sender).SetValue(Canvas.TopProperty, canvasTop + Top);
            canvasLeft = Canvas.GetLeft(((Image)sender));
            canvasTop = Canvas.GetTop(((Image)sender));
        }
    }
    
    void myimg_MouseDown(object sender, MouseButtonEventArgs e)
    {
        mouseClick = e.GetPosition(null);
        canvasLeft = Canvas.GetLeft(((Image)sender));
        canvasTop = Canvas.GetTop(((Image)sender));
        ((Image)sender).CaptureMouse();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I want use html5's new tag to play a wav file (currently only supported
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.