473,405 Members | 2,279 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Passing Events to children

This is a WPF application with C#.

I have UserControls on a canvas. I have enabled the ability to drag and move these UserControls anywhere on the canvas. The problem comes up when these UserControls have an extender in them. For some reason, it would appear that the extender is not getting the event. So it never extends.

I'm wondering how to fix this. Now if i set Handled to false, it will extend, but my click and dragging will lock up fairly randomly, normally within 2-3 drags.

event is
Expand|Select|Wrap|Line Numbers
  1.         protected override void OnPreviewMouseLeftButtonUp(System.Windows.Input.MouseButtonEventArgs e)
  2.         {
  3.  
  4.  
  5.                 if (m_isDown)
  6.                 {
  7.                     DragFinished(false);
  8.                     (m_originalElement as ComponentControl).
  9.                     e.Handled = true;
  10.  
  11.                 }
  12.  
  13.  
  14.          }
DragFinish just takes a bool to know if it was cancelled or not, so this is saying on the mouseup event, to finish the drag (set the object down) and handle the event. The start code always starts on the mouse button down. It looks like...

Expand|Select|Wrap|Line Numbers
  1.  protected override void OnPreviewMouseLeftButtonDown(System.Windows.Input.MouseButtonEventArgs e)
  2.         {
  3.                 if (e.Source != this)
  4.                 {
  5.  
  6.                     m_isDown = true;
  7.                     m_startPoint = e.GetPosition(this);
  8.                     m_originalElement = e.Source as UIElement;
  9.  
  10.                 }
  11.                 e.Handled = false;
  12.                 base.OnPreviewMouseLeftButtonDown(e);
  13.  
  14.         }
so with those two functions, if i turn either of the e.handled to true, i can't extend, if i have them the way i have it now, it locks up. So what i'm trying to figure out is how i can in this event, send a mouseUp event to the extender.

sorry if i seemed to kind of jumble around a bit, but this problem is confusing.

To recap:
setting handled to false allows me to extend, but freezes when i move the object.
setting handled to true allows me to move, but i cannot extend.
Mar 21 '08 #1
1 1288
does anyone have an idea on how to get it so the canvas can pass the mouse event to the child?
Mar 24 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Bonzo | last post by:
Another smart pointer problem. I have a tree structure. The idea is for parents to have SmartPtr's to the children, with children holding a weak pointer (WeakPtr) back to the parent. That's great,...
2
by: Kyzer | last post by:
Hi all, I have created a class which contains many TShapes, TLabels and TPanels. What I want to be able to do is when creating this class, is passing in a pointer to OnMouseDown and OnMouseUp...
2
by: DaRik | last post by:
Hi, I'm having some difficulties with a menu I'm making. I build up the menu through DOM. I append childnodes to a tree. 2 types of children are possible: url (a hyperlink) and sub (a submap). ...
5
by: Tim Menninger | last post by:
I have seen the postings about passing XML into an XSL transformation. The problem is that I cannot use any XPath navigation in the XSL that won't generate an error. If I use <xsl:copy-of...
3
by: Sasha | last post by:
Hi everyone, Here is my problem: I have the following classes: - DataNode - this class is designed to hold some data and will be contained in a tree like data structure DataTree. When...
8
by: Waleed Seada | last post by:
Hi all What need to be done to get the MDI parent call his MDI children Events, methods Thanks in advance /WS
2
by: Arnaud Diederen | last post by:
Hello, I cannot succeed in getting any key event on a div that's been set invisible by the style's MozOpacity property under firefox. I'm using this method so that I can capture the mouse...
4
by: simon | last post by:
hi, I would like to separate my javascript completely from my xhtml. in the end there should be only <script type="text/javascript" src="javalib.js"></script> in the head-tag to my javascript....
2
by: Israel | last post by:
It seems like there should be a way to pass events around like delegates but on the other hand they’re sort of special delegates because the only one allowed to invoke them is the owner of the...
8
by: Rex the Strange | last post by:
Hello All, I don't know if this is possible, but I'll give it a shot, here. I'm sick of writing the following line of code in control event handlers: if not visible then exit sub Is it...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.