Silverlight mouse events stop working if custom cursor used

I have a silverlight application in which I replaced the Mouse Cursor with a csuomt using the following code:

UserControl: CustomC.xaml

<UserControl...> <Canvas> <Image x:Name="EGCursor" Visibility="Collapsed"></Image> </Canvas> </UserControl>

UserControl: CustomC.xaml.cs

public void SetSource(string resource) { EGCursor.Source = new BitmapImage(new Uri(resource, UriKind.Relative)); EGCursor.Stretch = Stretch.None; } public void MoveTo(Point pt) { EGCursor.Visibility = Visibility.Visible; EGCursor.SetValue(Canvas.LeftProperty, pt.X - 13); MyCursor.SetValue(Canvas.TopProperty, pt.Y - 12); }

MainWindow.xaml

<UserControl x:Class="SL.MainPage"... Cursor="None"> ... </UserControl>

MainWindow.xaml.cs

MainWindow() { CustomC = new CustomC(); CustomC.SetSource("GlowingCur.png"); LayoutRoot.Children.Add(CustomC); } void MainPage_MouseMove(object sender, MouseEventArgs e) { CustomC.MoveTo(e.GetPosition(null)); }

On doing the above for a custom cursor, the click events on my silverlight MouseLeave, MouseClick etc. all stop working. How do I correct this behavior so that only the mouse cursor is replaced and other events that have been already coded work the same?

-------------Problems Reply------------

Try setting IsHitTestVisible to false on your custom cursor control:

CustomC = new CustomC();
SutomC.IsHitTestVisible = false;
CustomC.SetSource("GlowingCur.png");
LayoutRoot.Children.Add(CustomC);

Category:c# Views:0 Time:2012-03-16

Related post

  • Simple silverlight mouse event question 2010-01-06

    A simple silverlight app: <Grid x:Name="LayoutRoot"> <Canvas x:Name="C1" MouseLeftButtonDown="C1_MouseLeftButtonDown" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> <Canvas x:Name="C2" MouseLeftButtonDown="C2_MouseLeftButto

  • intercept mouse events when creating a custom QGraphicsItem 2011-01-21

    I am using a standard QGraphicsView and QGraphicsScene, but I have subclassed a QGraphicsPixmapItem to my own ImagePixmapItem for the purposes of being able to use the mouse events on the ImagePixmapItem. What do I need to do to be able to capture th

  • Silverlight Mouse Events: MouseEnter and MouseLeave conflicts 2011-11-24

    I have a collection of buttons in a grid. For each one of these buttons, I want to handle the MouseEnter and MouseLeave events to animate the height of the button (and do some other interesting stuff). It all works good until I start moving my mouse

  • silverlight mouse event 2010-07-22

    I am creting some border objects on a canvas through code behind. I don't have any XAML for these borders. Their opacity by default is set to 0.5 and I want to change their opacity to 1 on mouse enter. This is the code I have to try and make a mouse

  • Flex: How to avoid flickering cursor for custom cursor on mouse down 2009-03-31

    I set a custom cursor using the CursorManager on a sprite's mouse down event. The custom cursor is shown. However, when I keep the mouse pressed the system cursor shows as well and is flickering. Any idea how to prevent this? I tried - higher cursor

  • Silverlight: Is it possible to use custom mouse cursors/pointers? 2010-04-28

    I have just found this page indicating the support for Silverlight mouse cursors: http://msdn.microsoft.com/en-us/library/system.windows.input.cursor(VS.95).aspx Is that it!!! :-| what are they thinking, at least there is stylish looking Eraser! Is t

  • Flash - In right click context menu mouse cursor not visible when using a custom cursor 2009-07-27

    I'm using Flash actionscript2.0 and I'm using this code to show a custom cursor. onEnterFrame = function() { Mouse.hide(); myCursor._x = _xmouse; myCursor._y = _ymouse; } But this results in disappearing mouse cursor when viewing right click context

  • Silverlight 3.0 Custom Cursor in Chart 2010-04-14

    I'm probably overlooking something that will be obvious when I see the solution, but for now... I am attempting to use a custom cursor inside the chart area of a Toolkit chart. I have created a ControlTemplate for the chart, and a grid to contain the

  • Catching mouse events for a custom SplitContainerDesigner 2010-07-16

    I'm trying to create a user control that will provide a draggable splitter between two panels — exactly like SplitContainer — in a custom IDesignerHost implementation. SplitContainer itself, as far as I can tell, is not an option; it will raise an ex

  • Issue in chrome when using cursormanager(Its Displaying both custom cursor and normal mouse pointer) 2011-02-09

    I am using cursor manager to set the hand cursor for the overlay. its works fine in mozilla firefox and IE8, but in chrome its shows the hand cursor and also the normal mouse pointer, here is my code import mx.managers.CursorManager; import mx.manage

  • About flickering mouse custom cursor in ActionScrip3 2011-09-19

    I have a problem with flickering mouse custom cursor. I have a timeline which is my main clip and I want to show a pencil like cursor when I am over the timeline movie clip. I am using standard Mouse events, MOUSE_OVER and MOUE_OUT, MOUSE_MOVE. Also

  • custom cursor in actionscript 3 event doesn't work 2010-03-27

    the custom cursor is a sprite. using it to click another sprite no longer triggers the MouseEvent.Click event. it looks like my custom cursor is being clicked on the sprite i want to click Is there something i need to enable? --------------Solutions-

  • Global application hook for mouse events in Silverlight 2010-05-19

    Is there any way to register a global event handler for catching mouse events in a Silverlight application? I'd like to avoid subscribing to the mouse event handlers of each FrameworkElement and find a more elegant solution (bubbled events). Thanks -

  • Getting Custom NSCell with NSButtonCell instance to handle mouse click/mouse events 2010-06-10

    OK I'm really stumped on this one. I want to make a checkbox with a NSTextFieldCell combined together. It's important that the checkbox goes ON if the mouse hits the box, NOT the text. I've accomplished this, more or less, but the issue is receiving

  • How do I Manually Invoke/Raise Mouse Events in Silverlight 4? 2010-07-14

    In Silverlight 4, I wish to invoke one of the mouse button click events when the right mouse button is clicked. I have the RightMouseButtonDown click event wired up, but I don't know how to manually fire the MouseLeftButtonUp event. I have tried rais

  • Loss of Silverlight mouse up events after mouse capture? 2010-07-16

    I created a very simple test control that has a Rectangle on a canvas (within other containers, but inconsequential). The Rectangle has event handlers for mouse down, mouse move, and mouse up. If I capture the mouse in the Rectangle's MouseLeftButton

  • WPF custom panel control doesn't respond to mouse events 2011-01-13

    I've created a custom panel control and would like to have it respond to a mouse move event, however, when I add an event handler like so: Private Sub FloatingPanel_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles Me.MouseMove End

  • Possible to get mouse events fired when cursor is outside page? 2011-01-20

    I'm creating a game in which one can hold the mouse button and drag it around to rotate an object. However, when the mouse position is outside the page bounds, all mouse events are not fired anymore. This means that the object isn't rotated anymore w

  • Mouse event not working in Silverlight Grid 2011-06-21

    I Have created a Grid (g1) with a TabControl (t1). t1's TabItem content has Grid (g2). g2 has another TabControl as t20,t21,t22 (vertical TabControl) and each t2 series TabItem has another Grid (g3) . The issue I'm having is that a mouse event is not

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.091 (s). 11 q(s)