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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:03:37+00:00 2026-06-15T20:03:37+00:00

A WPF application consists of a uniform grid of arbitrary size. Each cell in

  • 0

A WPF application consists of a uniform grid of arbitrary size. Each cell in the grid contains a canvas. Each canvas is a target for a drag and drop operation.

When I drag another canvas and drop it onto a canvas inside the grid I want the top left corners of the dragged canvas(source) and the target canvas to align, essentially placing the source on top of the target. The behaviour I’m looking for is a snap-to-grid effect.

Currently when I use element.GetValue(Canvas.LeftProperty) the result in NaN. The problem is to determine the position of the corner for a canvas inside the grid, but relative to the entire window. I would prefer to use the grid, as it automatically resize as the window resize.

Is it possible to get the actual position of a canvas inside a grid even when the grid size changed or alternatively specify a canvas to be aligned to another canvas inside the grid?

  • 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-15T20:03:39+00:00Added an answer on June 15, 2026 at 8:03 pm

    This problem was solved by drawing each canvas onto another canvas by specifying the top and left properties of the canvas, I had to scratch the grid. I specified the position of every canvas by using

    Canvas.SetLeft(Me, position.X)
    Canvas.SetTop(Me, position.Y) 
    

    where Me is an instance of the canvas.

    It is now easy to get the top and left properties of every canvas. The only problem now is I have to implement the resizing of every canvas manually.

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

Sidebar

Related Questions

The WPF application I've created contains a Grid with 3 rows. I have a
I am building an application in WPF. It consists of a complex background (Canvas
My WPF application consists of a main window with a tab control which has
I have an application that consists of a WPF UI with an infrastructure layer
I am developing a WPF application which consists of a single window and many
I'm creating a WPF application using the MVVM design pattern that consists of a
The main window of our WPF application consists of 4 regions, arranged as 2x2
I have a WPF application which layout consists of 3 rows in a top
My WPF application has a TabControl with 4 TabItem's. Each TabItem has a different
I have a view in my .NET4 WPF application that consists of a TextBlock,

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.