How to implement scrollviewer bouncing's animation in c# and wpf? - c#

I want to implement scrollviewer bouncing's animation in c# and wpf, like IOS's UIScrollview.
When users scroll to top or end, it starts to decrease speed and bouncing.
I think that google can search related issues, but i can not find.
Does anyone have similar experiences?

Well for touch manipulation, WPF already has some built in support for this. Take a look at the ReportBoundaryFeedback method and ManipulationBoundaryFeedback event. I believe the ScrollViewer automatically uses this when touch panning (see PanningMode).

Related

What WPF control to use for a series of images (like Netflix, Hulu, etc..)?

New to .Net and Visual Studio. Quickly learning. As my first application, I am building a program similar to Netflix and Hulu (without the streaming part). Coming from a web background, I'd use tables and divs to accomplish what I am trying to do.
What component would I use to create a series of thumbnails (as you would find on Netflix) of the movie / TV show. Provided an image below as an example.
It would continue on with horizontal scroll. I understand this would be non trivial and I'm not expecting a direct answer. However, I am resourceful person and only would need to be pointed in the right direction.
Thank you.
You should use an ItemsControl variant which could be ListView with ScrollViewer.
Or, a WrapPanel with ScrollViewer.
Or, a UniformGrid.
Apply scrolling support using Animation.

WPF - touch gestures - suppressed mouse click if scrolling

I have multiple videos in ScrollViewer and when I click on one of these videos It plays and I got movie on fullscreen and where I moved with scroll bar It's moving with videos. This is okay. I have implemented this by adding mouse click to media element and now I am testing this on touch screen and it's working.
But I want to differentiate between click on video and moving in that area. That user don't want to "select" video but he is just moving with area but not in scroll bar but in area with videos. For better understanding I added image:
To have WPF make difference between click and move (to have both but still calling just one). What is the best way to do this? Thanks
It is very hard to handle touch events on your own, especially when you have to handle nested controls.
I think the easiest way to solve this, is for you to use the Microsoft Surface Touch Pack
Replace your ScrollView with a SurfaceScrollView and place a transparent SurfaceButton above your MediaElements and react on the Click-event (or handle it via the a command).
This way, Microsoft does the tricky panning (scrolling) or tapping (clicking) for you. And as a nice side effect, you get things like bouncing and interia of the ScrollViewer for free.

How to change ListView background image layout?

I've tried to find a way to change the layout of the background image on the ListView control.
I've searched around but haven't got any straight answer.
I can see that there is a ListView property BackgroundImageLayout which is supposed to do the job. But when i change it nothing really happens beside that the BackgroundImageLayoutChanged event is triggered.
How it is possible to change the BackgroundImageLayout on the ListView control? Is there any possible workaround to achive my goal?
PS.: I know about 3rd party controls that 'fix' this problem, but I'm looking for a solution that would do the task without any additional components.
ListView is a native Windows control. Yes, it does support a background image, the LVM_SETBKIMAGE message takes care of it. It however doesn't support the boilerplate Winforms BackgroundImage support, notable lacking is BackgroundImageLayout, the property that Winforms implements for the Control class and implements when the ControlStyles.UserPaint is turned on. It is not for native Windows controls, they paint themselves.
The guy that wrote the Winforms wrapper class for ListView did the next best thing, he added a new property to the ListView class called BackgroundImageTile. A layout option that the native Windows control does implement. Which leaves you with just the two layout options that the native control supports. Tile or don't tile.
That same guy did some pretty heroic things to make the Winforms wrapper class behave reasonably. The code is filled with hacks to work around the native control's quirks. Awesome work. His life would have been a lot easier if the Windows team guy would have the luxury to make the Winforms guy's life easier. But it doesn't work that way, ListView has been around a lot longer than Winforms. And wasn't designed that well from the getgo, Microsoft had pretty significant growing pains around that time.
Fast forward and change the rules so you don't depend on legacy code: WPF, Silverlight, WinRT.
According to the MSDN, 'ListView.BackgroundImageLayout Property':
"The API supports the .NET Framework infrastructure and is not
intended to be used directly from your code."
and
This property has no effect on the layout of the background image of the ListView control, therefore it is not shown in the designer or by IntelliSense.
Use the BackgroundImage property to set the background image. See msdn for more info:
That is unless you have something fancy you are trying to do with it?
EDIT: As per a previous thread HERE: the short answer is that you can't. =(
If you desparately want it, try creating a blank image that is the dimensions of your ListView. Add to this image YOUR image and add at it a position that is in the middle. There may be something similar in nature to this in under Bitmaps or Images.

WPF container that allows objects to move around

I worked a litte with WPF but it used copy-paste for XAML and mostly C# coding for the background logic. Now I want to start a project with a friend and use WPF because it will be a GUI intensive one.
Question:
In our app, we want to have a surface on which we can put objects and the user should be able to move the objects around. This should be 2D. By moving, I mean click on an object and drag it around inside the surface. In the end, I think the movement should be only in one direction ( only horizontal), but for the moment it should be possible to move them in any direction. The only restriction that should apply is that they can't remain one on top of the other.
Can you give me any hints on what container should we use for the surface, what base class should we use for the objects moving in the container? Or does WPF have something that works out of the box for this case? General hints how we should start this would be appreciated.
I know that this is a lot for some one that doesn't have so much experience with WPF but I did the same thing when I came from C++ to C# and it worked :).
Canvas is always a good container to move things around.
Have a look at this article on CodeProject:
WPF Diagram Designer: Part 1
It uses a Canvas to display items, and implements code to allow the items to be dragged around the Canvas.
This is a blogpost from version .NET 3.5
http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/05/08/test-post-1.aspx
"Dragable" is a common case when discussing the topic of behavior in expression blend.

How can I create a finger scrollable Textbox in WM 6.5?

I just noticed something weird in WM 6.5 emulators. Unlike 6.1 where finger panning kind of worked, the only way to scroll a Textbox appears to be through scrollbars.
This behaviour is in contrast to what they have done for comboboxes: they are now gesture-friendly without the programmer's intervention. I.e. the user can select a choice from a standard drop down menu by panning and scrolling. Previously, you had to use the embedded scrollbar. The combobox's case implies that MS took some measures to provide standard gesture support for classic finger gestures, yet I cannot see something similar for textboxes. This makes me ask the following:
Is there anything that can be done to make textboxes finger scrollabe easily?
Note that I refer to managed .NET CF development. It is my understanding that in native development I could use the new Gestures API to achieve the scrolling effect. Yet, I am not sure if there is an easier and more straightforward method that I have missed.
Create a textarea and limit it to two rows: one for text, one for a scrollbar.
You could try using the gesture api, there are managed wrappers for it...
http://blog.markarteaga.com/CategoryView,category,Samples.aspx

Categories