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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:10:41+00:00 2026-05-24T20:10:41+00:00

I have a grid like this: <Grid> <WrapPanel Name=wrap1/> <Canvas Name=canvas1 Background=LightGray Opacity=0.5/> </Grid>

  • 0

I have a grid like this:

    <Grid>
        <WrapPanel Name="wrap1"/>
        <Canvas Name="canvas1" Background="LightGray" Opacity="0.5"/>    
    </Grid>

And I want to be able to:

  • capture click events for the WrapPanel buttons
  • capture mouseLeftButtonDown, mouseLeftButtonUp, mouseMove events for the Canvas

WrapPanel Button PreviewMouseLeftButtonDown and Click doesn’t work. Also putting Canvas inside WrapPanel or WrapPanel inside Canvas doesn’t work.

  • 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-24T20:10:42+00:00Added an answer on May 24, 2026 at 8:10 pm

    Your WrapPanel and Canvas are not in a parent / child relationship in the VisualTree. The WrapPanel does not contaim the Canvas, so the mouse events do not bubble up. You need to contain the Canvas in the WrapPanel and then the events should be available to both.

    Edit:

    Here is my code that fires both events (I also bound my Canvas width/height to the containing WrapPanel so it would fill the panel):

    <WrapPanel Name="wrap1" MouseLeftButtonDown="wrap1_MouseLeftButtonDown">
        <Canvas Name="canvas1" 
            Width="{Binding ElementName=wrap1, Path=ActualWidth}" 
            Height="{Binding ElementName=wrap1, Path=ActualHeight}" 
            Background="LightGray" Opacity="0.5"
            MouseLeftButtonDown="canvas1_MouseLeftButtonDown"/>
    </WrapPanel>
    

    Remeber that Preview events are top down in the VisualTree where as non-preview events are bottom up, so if you use the Preview events, the WrapPanel events will fire first, but this code will fire the Canvas event first.

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

Sidebar

Related Questions

I have a Grid inside a Canvas defined like this: <Canvas x:Name=outerCanvas> <Grid Grid.Row=1
Hai presently i have grid like this. <Grid Name=tGrid1 Grid.Row=0 Background=Black > </Grid> <Grid
I have something like this in my xaml: <Grid> <Image Name=image Source=../../Images/DefaultImage.png HorizontalAlignment=Stretch VerticalAlignment=Stretch></Image>
i want to have a grid inside a div grid like this one: http://www.chinolatino.eu/
I have grid something like this: Ext.define('Exp.view.dashboard.Tv', { extend: 'Ext.grid.Panel', initComponent: function() { this.columns
I have a function creating entries via grid() like this: (replace while-loop with function,
Let's say I have some grid that looks like this _ _ _ _
I have a View that is basically setup like this: <Grid> <ViewBox> <Grid> <ItemsControl
I have a grid something like this: A A A A A B C
I have a grid like this: 1234567 1 ACBDBAB 2 ABDBABC 3 ABADBAB 4

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.