Scroll Event in WPF - c#

I have a question, how to handle the scroll event when I scroll my mouse to adjust volume of a MediaElement?

I think you are looking for the UIElement.MouseWheel event.
I'd offer more, but I don't know how your app is structured. If you are using MVVM, etc.

Related

WPF Programmatically Enable TextBox Scrolling/Panning for Tablets

I am working with a WPF application that will be used on Windows tablets. The issue I am having is that I cannot scroll through a large multi-line TextBox on a tablet by pressing and dragging the content. However, it still scrolls on a desktop with a mouse wheel.
This question (Enable swipe scrolling on Textbox control in WPF Scrollviewer) seems to answer the same problem I am having, but I need to do it programmatically. This is what I am doing to set the panning mode of the TextBox:
txtLongText.SetValue(ScrollViewer.PanningModeProperty, PanningMode.None);
Which I can tell is working because the click & drag text selection is now disabled, but the content still does not scroll. I am also setting the panning mode of the outer ScrollViewer as such:
popupScrollView.PanningMode = PanningMode.Both;
The popupScrollView object is then being set as the content inside a Popup.
The only thing I can think of is if there is somewhere else higher up that I need to be setting the panning mode? Any help would be appreciated. Thanks.
i have same problem with touch devices. i have a tricky way to handle this kind of issues
You have to handle touch event manually
i have written some codes to handle touch events manually
when UIElement_OnTouchDown(object sender, TouchEventArgs e) event occurred you can keep position of touched position by eventArgs.GetTouchPoint(this).Position.Y.
after that, you can determine is scroll happened or not by watching the position changes.
here is my sample gist
, i use this approach for same issue with touch devices
I think you require to use three properties to achieve this.
ScrollViewer.PanningMode
ScrollViewer.PanningDeceleration
ScrollViewer.PanningRatio
By default, PanningMode sets to None, but set it to another value will enable touch scrolling.
Another thing you can try is to set ScrollViewer CanContentScroll to true.
While Im not sure there is a viable way to solve that using wpf only, I recommend trying to implement html UI inside your wpf application using DoNetBrowser, link.
Then you can use the textarea control in html, which in default lets you scroll on mobile.
Hope this answer helped you.

Global mouse events

Hallo,
I am trying to keep track of the mouse position and also its delta position. Is there any nicer way of doing this then implementing all the mouse events for all my forms in my window?
The problem with using the MouseMove event is that as soon as the mouse moves outside of the form it stops working properly. Implementing the mouseEnter, mouseLeave improves it somewhat, but it does still not feel perfect. Any ideas?
Regards,
You have to handle lower level windows events.
Check out this example: http://www.codeproject.com/KB/cs/globalhook.aspx

silverlight mouse position c#

Is there a way to get mouse position without attaching a event handler?
I'm trying to get a box to appear where the mouse is.
Thanks
Sp
Wouldn't you rather want it on a mouse-up or mouse-down event? Here are a few drag-and-drop tutorials that might help with ideas for capturing mouse positions:
http://msdn.microsoft.com/en-us/library/cc189066%28vs.95%29.aspx
(SL 1, but still good) http://blogs.msdn.com/b/nickkramer/archive/2007/06/27/drag-drop-with-feedback.aspx
Unfortunately, I think you'll have no other way than using the MouseMove event. You can attach it to the Application.Current.RootVisual (or any other layout root) though, so you should be able to implement your scenario.

Looking for suggestions on how to create an enhanced tooltip

currently I am using a tool tip to display information when it hovers over a region on a winform. This works well and I don't have any complaints, but the boss want's to display more complex data, that would best be displayed in a grid rather than text.
Is there a way that perhaps I could embed a usercontrol or a datagridview in a tool tip.
thanks
C#, .Net 2.0, windows.Forms
There's such a thing as an owner-drawn tooltip. You'd have to handle the painting of the grid yourself. You wouldn't get any interactivity, although a tooltip that lets you click and scroll sounds odd anyway.
If your boss is willing to spend money on this then I can happily recommend the DevExpress tooltip control, for its customisability.
You can write a custom control (shouldn't be too hard, just a yellow rectangle with a drop shadow) with a data grid on it. It just needs to fade out when the mouse moves away and get displayed after the mouse rests on it for a couple of seconds.

Make ListView scroll vertical by MouseWheel

How can I make a WinForms ListView scroll vertical by MouseWheel?
I'm using C#.
Is it OK if the list scrolls only when it has focus? If so, use the Control.MouseWheel event.
Do you want the list to scroll if it doesn't have focus? Then you need to need to either implement a mouse hook, as described in the other article, or take a look at the Application.AddMessageFilter method. Application.AddMessageFilter gives you a managed version of a mouse hook. You get to preview the messages as they come in. I wrote something about it here.

Categories

Resources