![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
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.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| 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 Specs![]() |
| | #2 (permalink) |
| 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 Specs![]() |
| | #3 (permalink) |
| 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 Specs![]() |
| | #4 (permalink) |
| 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 Specs![]() |
![]() |
| 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 |