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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:01:42+00:00 2026-06-09T21:01:42+00:00

I want to add an Image dynamically to the wpf application. What I have

  • 0

I want to add an Image dynamically to the wpf application.

What I have tried :

            Image img = new Image();
            img.Height = 100;
            img.Width = 100;
            img.Visibility = Visibility.Visible;

            Thickness th = new Thickness(100, 100, 0, 0);
            img.Margin = th;

            string strUri2 = String.Format(@"pack://application:,,,/MyFirstWPF;component/Images/tt.jpg");
            img.Source = new BitmapImage(new Uri(strUri2));

I know, the image won’t display unless I add it to the Content.

this.Content=img;

but with this the existing controls(shapes) on the app are lost.

Now, my question is how to add the image to the content without losing existing controls from the app.

  • 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-09T21:01:44+00:00Added an answer on June 9, 2026 at 9:01 pm

    When you are going to load and show an image dynamically, you still need to think about the layout of your application. I would suggest to add an (initially empty) Image control in XAML (for example in a Grid), and later set the Source property of this control in code.

    <Grid>
        ... other controls ...
        <Image Name="img" Grid.Row="..." Grid.Column="..."
               Width="100" Height="100" Margin="100,100,0,0"/>
    </Grid>
    

    Set Source in code:

    var uri = new Uri("pack://application:,,,/MyFirstWPF;component/Images/tt.jpg");     
    img.Source = new BitmapImage(uri);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to add text dynamically on an image. I tried to use javascript
I have an array of Image URLS .I want to dynamically add Pivot item
I want to add an image, instead of the default button. I already have
I am very new to Java, I want to add a PNG image to
Hi an developing drawing android application. in that i want to add a sticker(image)
I want to put em tag before IMG tag dynamically , the image class
I want to add different image to c# windows form datagridview row header dynamically.
I have a Java Project in NetBeans 7.0. I want to add some image
I want to add a number of image views to a HorizontalScrollView dynamically. I
I want to dynamically add image in EditText . Is it possible? if anyone

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.