Windows Vista Forums
Vista Forums Home Join Vista Forums Webcasts Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Avalon

Catching and processing mouse events

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 04-12-2006   #1 (permalink)
Jason [Mobiform]
Guest


 

Catching and processing mouse events

Heres my scenario, I have a ScrollViewer with a stack panel which contains a
bunch of expanders, each expander has a ListBox with some ListItems. The
problem is that the scrollview will not respond to mouse wheel events if the
cursor is over a list item. My temporary solution is to have all ListItems
raise the mouse wheel event on the ScrollViewer when a ListItem.MouseWheel
event is triggered. This is not a good solution if I dont have total control
over the ScrollViewer contents, it works but there must be a better way...
It would be nice if I could just have a ScrollViewer.PreviewMouseWheel
capture this event and respond to it assuming nothing else has explicitly
handled that event. What is the correct procedure to do this?



My System SpecsSystem Spec
Old 04-12-2006   #2 (permalink)
Nick Kramer [MSFT]
Guest


 

Re: Catching and processing mouse events

Mouse wheel is supposed to scroll the thing it is over, which in your case
is the listbox. Your "temporary" solution seems like a fine solution to me,
but I'm not clear on the desired behavior. Are you trying to always
scrolled the scroll viewer no matter what? Or scroll everything inside the
scroll viewer except for list boxes? Were something else?

If you are trying to scroll the scroll viewer, I'd handle
ScrollViewer.PreviewMouseWheel and make the viewer scroll, either by calling
OnMouseWheel or by calling ScrollViewer.LineUp/Down directly.

-Nick Kramer [MSFT]

---
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

"Jason [Mobiform]" <Jason@mobiform.com> wrote in message
news:OY3BLJlXGHA.1348@TK2MSFTNGP05.phx.gbl...
> Heres my scenario, I have a ScrollViewer with a stack panel which contains
> a bunch of expanders, each expander has a ListBox with some ListItems. The
> problem is that the scrollview will not respond to mouse wheel events if
> the cursor is over a list item. My temporary solution is to have all
> ListItems raise the mouse wheel event on the ScrollViewer when a
> ListItem.MouseWheel event is triggered. This is not a good solution if I
> dont have total control over the ScrollViewer contents, it works but there
> must be a better way... It would be nice if I could just have a
> ScrollViewer.PreviewMouseWheel capture this event and respond to it
> assuming nothing else has explicitly handled that event. What is the
> correct procedure to do this?
>



My System SpecsSystem Spec
Old 04-12-2006   #3 (permalink)
Jason
Guest


 

Re: Catching and processing mouse events

> Mouse wheel is supposed to scroll the thing it is over, which in your case
> is the listbox


That makes sense, I forgot that a list box would scroll given the right
conditions. However, I have set them up in such a way that they scale to the
content and should never need to scroll. I'm trying to have the scrollviewer
scroll all the time, the list boxes dont have content to scroll so I was
assuming that the list would pass off the wheel event to somewhere up the
logical tree.

I tried to override ScrollViewer.PreviewMouseWheel but I didnt see a
OnMouseWheel on the ScrollViewer, I will look again. The only option I saw
was to raise another MouseWheel event there ( RaiseEvent(e) ), which didn't
seem to work quite right ( I think I would have to create a new event and
set the source to the scrollviewer ). LineUp/Down seems like the right way
to go.

Thanks for your help,
Jason


"Nick Kramer [MSFT]" <nkramer@Microsoft.com> wrote in message
news:eh43wipXGHA.3448@TK2MSFTNGP03.phx.gbl...
> Mouse wheel is supposed to scroll the thing it is over, which in your case
> is the listbox. Your "temporary" solution seems like a fine solution to
> me, but I'm not clear on the desired behavior. Are you trying to always
> scrolled the scroll viewer no matter what? Or scroll everything inside
> the scroll viewer except for list boxes? Were something else?
>
> If you are trying to scroll the scroll viewer, I'd handle
> ScrollViewer.PreviewMouseWheel and make the viewer scroll, either by
> calling OnMouseWheel or by calling ScrollViewer.LineUp/Down directly.
>
> -Nick Kramer [MSFT]
>
> ---
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> Use of included script samples are subject to the terms specified at
> http://www.microsoft.com/info/cpyright.htm
>
> "Jason [Mobiform]" <Jason@mobiform.com> wrote in message
> news:OY3BLJlXGHA.1348@TK2MSFTNGP05.phx.gbl...
>> Heres my scenario, I have a ScrollViewer with a stack panel which
>> contains a bunch of expanders, each expander has a ListBox with some
>> ListItems. The problem is that the scrollview will not respond to mouse
>> wheel events if the cursor is over a list item. My temporary solution is
>> to have all ListItems raise the mouse wheel event on the ScrollViewer
>> when a ListItem.MouseWheel event is triggered. This is not a good
>> solution if I dont have total control over the ScrollViewer contents, it
>> works but there must be a better way... It would be nice if I could just
>> have a ScrollViewer.PreviewMouseWheel capture this event and respond to
>> it assuming nothing else has explicitly handled that event. What is the
>> correct procedure to do this?
>>

>
>



My System SpecsSystem Spec
Old 04-13-2006   #4 (permalink)
Jason [Mobiform]
Guest


 

Re: Catching and processing mouse events

There is no OnMouseWheel function.

After playing a bit I have found that I can call LineUp/Down but the
resulting behavior is that the scrollviewer scrolls fewer lines than normal
on fast mouse wheel movement. So to get "normal" behavior I have to guess
how mousewheel deltas translates into multiple LineUp/Down calls. Is there
possibly something else I could do to remove the guesswork?

void _MainScroller_PreviewMouseWheel(object sender,
System.Windows.Input.MouseWheelEventArgs e)
{
e.Handled = true;
if (e.Delta > 0)
{
_MainScroller.LineUp();
}
else
{
_MainScroller.LineDown();
}
}
Thanks in advance
Jason

"Nick Kramer [MSFT]" <nkramer@Microsoft.com> wrote in message
news:eh43wipXGHA.3448@TK2MSFTNGP03.phx.gbl...
> Mouse wheel is supposed to scroll the thing it is over, which in your case
> is the listbox. Your "temporary" solution seems like a fine solution to
> me, but I'm not clear on the desired behavior. Are you trying to always
> scrolled the scroll viewer no matter what? Or scroll everything inside
> the scroll viewer except for list boxes? Were something else?
>
> If you are trying to scroll the scroll viewer, I'd handle
> ScrollViewer.PreviewMouseWheel and make the viewer scroll, either by
> calling OnMouseWheel or by calling ScrollViewer.LineUp/Down directly.
>
> -Nick Kramer [MSFT]
>
> ---
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> Use of included script samples are subject to the terms specified at
> http://www.microsoft.com/info/cpyright.htm
>
> "Jason [Mobiform]" <Jason@mobiform.com> wrote in message
> news:OY3BLJlXGHA.1348@TK2MSFTNGP05.phx.gbl...
>> Heres my scenario, I have a ScrollViewer with a stack panel which
>> contains a bunch of expanders, each expander has a ListBox with some
>> ListItems. The problem is that the scrollview will not respond to mouse
>> wheel events if the cursor is over a list item. My temporary solution is
>> to have all ListItems raise the mouse wheel event on the ScrollViewer
>> when a ListItem.MouseWheel event is triggered. This is not a good
>> solution if I dont have total control over the ScrollViewer contents, it
>> works but there must be a better way... It would be nice if I could just
>> have a ScrollViewer.PreviewMouseWheel capture this event and respond to
>> it assuming nothing else has explicitly handled that event. What is the
>> correct procedure to do this?
>>

>
>



My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Catching the messages on the fly Gokhan Dalkilic Live Messenger 1 01-02-2008 10:24 AM
SMO : Catching Exceptions dm_14 PowerShell 1 07-17-2007 10:40 PM
Manipulating mouse events through Powershell danielfeichtinger@gmail.com PowerShell 5 04-17-2007 05:19 AM
Simulating mouse events in WPF Keith Avalon 0 03-27-2007 08:48 AM
Fire events from Xaml files.. events in Pre compiled Dll's SureshGubba Avalon 1 09-15-2006 01:56 PM


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51