I want to scroll through the Diagram using MouseScroll and do the zoom operation by holding CTRL key and use mouse scroll up/down. By default MouseScroll does the zoom operations. I want to perform zooming by holding a CTRL modifier and MouseScroll. Is this possible?
5 Answers, 1 is accepted
Let me get straight to your questions. So, to achieve your requirements:
1) Zoom operation - you can subscribe to the diagram's PreviewZoom event and check if the Ctrl key is down, if not, you can cancel the zoom operation by setting the event arguments' Handled property to True.
2) Scroll operation - you can use the diagram's MouseWheel event and change the diagram's Y position with the e.Delta.
For your convenience I implemented this approach in the attached project. Please take a look at it and let us know if it works for you
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
I am attaching a sample project demonstrating how the desired requirement can be achieved with a native ListBox by handling the PreviewMouseWheel event. Please, check it out and let me know if it helps.
Additionally, since I noticed that you have written in several forum threads, may I kindly ask you to stick to a single thread which topic is close to your scenario? If there isn't one, you can open a separate forum thread. This will allow us to better organize our communication.
Thank you in advance for your understanding.
same code i was already tried but childrenoftype<ScrollViewer>() shows the error..
it shows assembly reference missing..
var scrollviewr = this.radGridViewRoomsSummary.ChildrenOfType<ScrollViewer>.FirstOrDefault();
error : SeverityCodeDescriptionProjectFileLineSuppression State
ErrorCS0119'ChildrenOfTypeExtensions.ChildrenOfType<T>(DependencyObject)' is a method, which is not valid in the given contextHeatTransferE:\......\View\RoomsSummaryDetails.xaml.cs95Active
Note, that the ChidlrenOfType extension method is defined in the Telerik.Windows.Controls dll and you need to reference it in order to use it.
Although I am uncertain why the mentioned error is received on your end, you can check out the following resource which I found while searching for it on the net:
- Is a 'method' which is not valid in the given context error
If the above information does not help, note that the ChildrenOfType extension method only searches for the children of a specific element of a given type. You can also implement this logic. Here is a thread, where a similar topic was discussed:
- Find all controls in WPF Window by type
Hope you find this helpful.