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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:31:38+00:00 2026-05-31T23:31:38+00:00

In my game I will draw a small map (i.e. 10×10 fields). Each field

  • 0

In my “game” I will draw a small map (i.e. 10×10 fields). Each field will represent a wall or ground. Depending on the answers to this question, the tiles will be either PNG images or simple color-filled rectangles.

What is your best recommended way to draw such a map in WPF? I want it to be as simple as possible, because the GUI part of this project is not very important, I just want it to be displayed in the center of the window.

Ideas that I have:

  • Canvas + placing multiple Rectangles as children
  • Bitmap rendered by engine, displayed by GUI
  • External library?
  • 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-31T23:31:40+00:00Added an answer on May 31, 2026 at 11:31 pm

    WPF is not so inclined toward drawing as Windows Forms is. WPF is more content-oriented.

    The best way to ‘draw’ something is to generate the map out of existing WPF elements. For example, you could use a Grid or UniformGrid, or even a Canvas to lay out your content. You could programmatically add Images and Rectangles to the map, without worrying about any drawing code.

    Here is an example:

    UniformGrid grid = new UniformGrid();
    grid.Columns = 10;
    grid.Rows = 10;
    grid.Width = columnWidth * 10;
    grid.Height = rowHeight * 10;
    for (int x = 0; x < 10; x++)
    {
        for (int y = 0; y < 10; y++)
        {
            if (fields[x, y] is SomeImage)
            {
                Image img = new Image();
                img.Source = someImageSource;
                grid.Children.Add(img);
            }
            else
            {
                Rectangle rect = new Rectangle();
                rect.Fill = someColor;
                grid.Children.Add(rect);
            }
        }
    }
    Canvas.SetLeft(grid, (canvas.Width - grid.Width) / 2);
    Canvas.SetTop(grid, (canvas.Height - grid.Height) / 2);
    canvas.Children.Add(grid);
    

    You probably won’t be able to use that as is, but you can fill in the missing pieces.

    I recently did a project similar to this, using a Canvas to lay out TextBlocks, Lines and Buttons. It is efficient and simple, a lot more than I expected.

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

Sidebar

Related Questions

My game will play 10 rounds, so each time you advance to a new
Hello I want to do a small web based game in which there will
Objects that are really large like, lets say a game map will outright not
I develop a game that will have to load jpg images that now i
We are making a game which will add a level editor feature soon. We
i am making a game which will ask different questions in java. questions are
I plan on writing a Java 3D game that will work both on PC
I'm working with xna in C# and in my game I will have a
How well will a Windows Phone 7 XNA game handle large textures, approximately 8000
I'm designing game site where many (hopefully thousands) players will simultenaously play certain card

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.