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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:41:20+00:00 2026-05-18T09:41:20+00:00

Greetings I started developing with WPF yesterday and have ran into some issues. I

  • 0

Greetings

I started developing with WPF yesterday and have ran into some issues. I came to the understanding that a Canvas was the equivalent to a Panel in WinForms. However I’m running into some difficulties with the ‘click’ event. The MouseLeftButtonDown event. If it’s relevant or not, this Image and the Canvasses are in a UserControl

Image + 3 Canvasses

The above image is basically what I am having difficulties with. The 3 images you see is one image. The squares you see are each different canvases. Depending on what canvas is clicked i want something different to happen.

Currently i have the following code:

<Grid>
    <Canvas Name="canvasTerran"  Height="27" Width="26" Margin="88,106,134,106" MouseLeftButtonDown="canvasTerran_MouseLeftButtonDown" />
    <Canvas Name="canvasZerg" Height="27" Width="26" Margin="117,107,105,107" MouseLeftButtonDown="canvasZerg_MouseLeftButtonDown" />
    <Canvas Name="canvasProtoss" Height="27" Margin="145,107,88,107" MouseLeftButtonDown="canvasProtoss_MouseLeftButtonDown" />
    <Image Name="imageRaces" Height="27" Width="73" Stretch="Fill" Source="pack://application:,,,/Images/Races/Races.png" />
</Grid>

When I run the application (the user control is in the main window ofcourse) and I click where the canvasses should be nothing happens. The event I’m trying to fire:

 private void canvasTerran_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            MessageBox.Show("lolterran", "lol");

            // image on main window
            // .Source = new BitmapImage(new Uri("pack://application:,,,/" + Constants.RACESPATH + "T.png"));
        }

I don’t really see what I’m doing wrong here so any suggestions would be welcome. As I said I’m new to WPF so if you think there is a better way than I’m currently trying please do say so!

Thanks in advance.

  • 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-18T09:41:20+00:00Added an answer on May 18, 2026 at 9:41 am

    The actual problem is that the canvases are transparent. Thus, all the events do not halt at canvas, but they are generated for its parent element.

    If you set Background=White or Red for example for a canvas, it should get MouseLeftButtonDown.

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

Sidebar

Related Questions

Greetings. I'm just getting started with the boost::asio library and have run into some
Greetings, I have an asp.net mvc application. I have some links that corresponds to
greetings all I have a cronExpression that I want it to be started on
greetings, today i have started to learn java using netbeans ide. i would like
Greetings! I have a Repeater control that's using an XmlDataSource control. <asp:FormView id=myFormView runat=server
Greetings! I recently started working for a company that carries a line of 20,000
In my Universal-App i have some issues where the app crashes. I could not
Greetings all. I am writing some code using the Boost Units library and have
Greetings, I have recently started to code in C++ and have come across a
Greetings! I have an issue here that i can't find. I am getting a

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.