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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:09:15+00:00 2026-05-24T13:09:15+00:00

Hello i have a canvas with the name Layout. I want to add some

  • 0

Hello i have a canvas with the name Layout. I want to add some childs to it in code behind. Here is the code.

private void AddItem(int TruePosition, int CurrentPosition, string ImageFileName)
{
    Image img = new Image();
    img.Source = new BitmapImage(new Uri(@"/Images/" + ImageFileName, UriKind.Relative));
    img.Width = 100.0;
    img.Height = 400.0;
    img.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
    img.Stretch = Stretch.None;

    Border b = new Border();
    b.SetValue(Canvas.TopProperty, 200.0);
    b.SetValue(Canvas.LeftProperty, (double)CurrentPosition);
    b.SetValue(Canvas.ZIndexProperty, 1);
    b.Background = new SolidColorBrush(Colors.Blue);

    b.MouseMove += new MouseEventHandler(Border_MouseMove);
    b.MouseLeftButtonDown += new MouseButtonEventHandler(Border_MouseLeftButtonDown);
    b.MouseLeftButtonUp += new MouseButtonEventHandler(Border_MouseLeftButtonUp);

    b.Child = img;
    Layout.Children.Add(b);
    UpdateLayout();
}

The image Uri is probably good because if i try to add only the border(without the image) it’s still not rendering. Also i call this AddItem function from a button click event handler so initializations should not be a problem. Probably i am missing a very basic stuff here. Any ideas are welcome, thank you for your help.

Update: Ok i had something wrong with the browser cache probably, the border is added, but the image in the border isn’t showing up. In the Visual Studio project i have an Images dir with the image files. Am i setting the path to them wrong?

  • 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-24T13:09:16+00:00Added an answer on May 24, 2026 at 1:09 pm

    So, now i am allowed to answer it. Well it was a newbie mistake.
    The first / before Images is not needed. new Uri(@”Images/” + ImageFileName, UriKind.Relative) is correct.

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

Sidebar

Related Questions

Hello i have 2 arrays and and i want to put them in a
hello I have my code that connects to my ftp server $conn_id = ftp_connect($ftp_server);
Hello I have this code class Triplets { public: int nVal1; int nVal2; NodeT
Hello I have the following code: if(_deviceSegmentCntrl.selectedSegmentIndex == 0) { deviceOne = [[NSString alloc]
Hello have only a few days with Java and android here. I am a
Hello i have designed a maze and i want to draw a path between
Hello i have this Gmap v3 code that shown the multiple markers (20 markers)
Hello i am unable to fire ontap() event i want to add a marker
Following code, credit: Guffa. Hello All, I'm trying to add controls to a Form
I have to use a canvas class to add frame and multiple images on

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.