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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:56:15+00:00 2026-06-14T05:56:15+00:00

I am using WPF and C# and I have a canvas with rectangles on

  • 0

I am using WPF and C# and I have a canvas with rectangles on it (like a maze). Now i want to create a character who moves (with the help of an algorithm) through this maze. Therefore I created a new class called character, but my problem starts here: How do I create an object on the canvas which has an image, a position and which can access the methods and attributes from the character-class?
So the final thing should look like this:

private class MainWindow
{

   //Here the canvas is made visible and the rectangles are being drawn on the canvas

   //Then a method should start to create the character and move him through the maze

   //it should look like (character.move(1) so the character moves one step forward etc.)

}

private class Character
{
//here are the methods and attributes the character should have
}

Thanks in advance and sorry for my bad english 🙂

  • 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-14T05:56:17+00:00Added an answer on June 14, 2026 at 5:56 am

    If you look at the problem from the opposite direction, it’s much easier to solve.

    Create your character object, hook it up so that everything works as you expect in your data (model). Then, you’ll want to add properties that represent the location of the character, such as

    public int XCoordinate { get; set; }
    public int YCoordinate { get; set; }
    

    Make sure the movement is done model-side. If you try to drive movement based on the visual display, it will over complicate the program.

    Next, define the view of the character in your canvas, something like this:

    <Canvas ...>
        <Image Canvas.Left="{Binding XCoordinate}" Canvas.Top="{Binding YCoordinate}" .../>
    </Canvas>
    

    Last, make sure your binding syntax is correct (did you set the DataContext?) and be sure to set up NotifyPropertyChanged to taste (both of these are well-covered elsewhere). Then you will be set up with a neatly divided model and view, and it should be much easier to focus on movement logic or whatever else you should desire.

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

Sidebar

Related Questions

I have been using WPF for a few years now and don't have any
I have a 16 bit grayscale image that I want to display using WPF
I'm trying to have a WPF canvas with rounded rectangles on that I can
I have a custom WPF Canvas, upon which I would like to show a
Using WPF I have a list of rectangles (which can have an undefined number
I am using Canvas in WPF Window to show UserControl. I dont want to
I have a C# application using WPF consisting of a single Window holding four
I have a c# program using WPF. I have it that when you press
I have a C# application of which some parts are written using WPF (which
I'm using WPF with .NET 3.0. I have a relatively simple DataTemplate defined as

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.