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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:14:34+00:00 2026-05-31T17:14:34+00:00

I am currently creating a program that dynamically adds Image to a dockPanel every

  • 0

I am currently creating a program that dynamically adds Image to a dockPanel every time a user presses a button. I was wondering how I could get it so that every time the user adds another image to the dockPanel the images shrink so that they are both the same size and fit inside the dockPanel.

Here is my current code:

 Uri myUri = new Uri(@"C:\Users\Jim\Desktop\Project\bin\Debug\pic.bmp", UriKind.RelativeOrAbsolute);
            BmpBitmapDecoder decoder2 = new BmpBitmapDecoder(myUri, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
            BitmapSource bitmapSource2 = decoder2.Frames[0];
        // Draw the Image
        Image myImage2 = new Image();
        myImage2.Source = bitmapSource2;
        myImage2.Stretch = Stretch.None;
        myImage2.Margin = new Thickness(20);
        dockPanel1.Children.Add(myImage2);

I tried doing myImage2.Height=80 and myImage2.Width=40 (thinking that it would change the size through percentage but it didn’t seem to work this way.

Any Ideas?

Thanks

  • 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-31T17:14:36+00:00Added an answer on May 31, 2026 at 5:14 pm

    I think you’d be better served by using a different container, specifically the UniformGrid container will do exactly what you want.

    Here’s a good tutorial: http://www.wpftutorials.com/2011/03/wpf-uniformgrid.html

    UPDATE

    UniformGrid may not be in the toolbox, but it is a built-in primitive so you do have it.

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

Sidebar

Related Questions

I'm creating a Win32 program that will be executed every time the computer turns
I am currently creating a program that recursively searches through the SD card of
I am currently creating a type of classifieds website, and when the user enters
I'm currently creating a user interface using WPF and would like to display a
I am currently creating a service which connects to a DAL and that can
I'm currently creating an MVC application that will likely to expand to include a
i'm currently creating a database program in java and i am a bit stuck
Basically I'm creating a forest fire program that depends on the wind / dryness
I'm currently creating a C# program which will be fetching some data over https
I am creating a program that displays several bases and the amount of troops

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.