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

  • Home
  • SEARCH
  • 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 8137543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:09:50+00:00 2026-06-06T11:09:50+00:00

When I create a dynamic image on a canvas, and then try ti find

  • 0

When I create a dynamic image on a canvas, and then try ti find it with visualtreehelper.getchild, it finds the image, but the offsets are 0.

It works if I use xaml to make the image, but not if I dynamically create it. Is there something you have to do extra if you create an image dynamically vs. in xaml to make visualtreehelper.getchild find the offsets?

 Dim iCount As Int16 = 0

    'Put Tables on Canvas
    For iCount = 0 To 5
        Dim tbl As New Image

        tbl.Source = New BitmapImage(New Uri("C:/Images/woodtable4.jpg", UriKind.Absolute))

        tbl.Width = 50
        tbl.Height = 50

        tbl.Name = "Tbl" & iCount.ToString
        Can1.Children.Add(tbl)

        Canvas.SetTop(tbl, 50)
        Canvas.SetLeft(tbl, (100 * iCount))
        'Can1.RegisterName(tbl.Name, tbl)
    Next

    'Get Child Objects

    Dim x As Int16
    Dim y As Int16
    For i As Integer = 0 To VisualTreeHelper.GetChildrenCount(Can1) - 1
        ' Retrieve child visual at specified index value.
        Dim childVisual As Visual = CType(VisualTreeHelper.GetChild(Can1, i), Visual)

        ' Return the offset vector for the TextBlock object.
        Dim vector As Vector = VisualTreeHelper.GetOffset(childVisual)
        ' Convert the vector to a point value.
        Dim currentPoint As New Point(VisualOffset.X, VisualOffset.Y)

        x = currentPoint.X
        y = currentPoint.Y
    Next i
  • 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-06T11:09:51+00:00Added an answer on June 6, 2026 at 11:09 am

    OK I found the answer after hours of research.
    When dynamically creating images on a canvas, after you are done, you need to call:

    <object>.UpdateLayout()
    

    in my case it is:
    Can1.UpdateLayout()

    Now I am getting the offsets returned to me correctly.

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

Sidebar

Related Questions

I'm attempting to use JQuery to create a dynamic page header using an image
Goal: I am trying to create a slightly dynamic page animated with basic canvas
I would like to generate a dynamic image from a script, and then have
I am using the following code to create a dynamic reflection of an image:
I want to create a custom control for a image regarding the dynamic zoom
I'd like to create a dynamic thumbnail resizer so that you can use the
On Android, I am trying to create a dynamic image viewer that flip images
Hi I wish to create dynamic file view gallery images but I have no
I am trying to create a dynamic image of my friends using PHP's GD
I am trying to create a dynamic image that will be created from PHP

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.