Xamarin.form drop-down refresh animation

Source: Internet
Author: User

It seems that there are few people in the garden who are interested in Xamarin ...

Come, first give you guys to make a laugh, the mountain master of the color starred in:

As usual, on the source:

Https://github.com/gruan01/ListViewExtend

Currently only WP effect, Android is still in research, IOS has not been planned.

------------------------------------------------------

The Xamarin.form ListView only supports drop-down refreshes (there are usage here), and the pull-up loads more events that do not correspond. This first put aside, today first talk about WP under, the bottom of the ListView pull painting effect of the replacement.

View Listviewrenderer with the anti-compilation tool

Onelementchanged, a fixedlonglistselector control is declared, then the control is set to Nativecontrol, and the control is pulltorefreshxxxx Event Settings handler.

My goal is simple, is to replace the falling pull drawing. So these events must be the entry point.

Fixedlonglistselector inherited from Longlistselector, unfortunately, it is internal! But it doesn't matter, it's easy to use reflection.

Clean/Add event handlers with reflection:

Private voidCleareventhandlers (ObjectObjstringevtname) {            vart =obj.            GetType (); //var fs = T.getfields (BindingFlags.NonPublic | bindingflags.static | bindingflags.instance);            varEVT =t.getevent (evtname); varF1 = T.getfield (evtname, BindingFlags.NonPublic |bindingflags.instance); if(EVT! =NULL&& F1! =NULL) {                varHandler =(EventHandler) F1.                GetValue (obj); varDS =handler.                Getinvocationlist (); Evt.            removeEventHandler (obj, handler); }        }        Private voidaddEventHandler (ObjectObjstringEvtname, Delegate handler) {            vart =obj.            GetType (); varEVT =t.getevent (evtname); Evt.        addEventHandler (obj, handler); }

Yesterday there was an interview that he used a lot of reflection, I casually asked how to use reflection to clean up the existing event handlers, and add their own handlers, the guy Gate thought for a while did not answer up, I am not a bit that ah ...

Ability to clean up and add event handlers is not enough, WP's longlistselector does not come with the pull drawing effect, XF is by adding a ProgressBar to do this effect, as follows:

This ProgressBar is invisible by default (progressbar.visibility = visibility.collapsed;), and the handler for the pulltorefreshxxxx event is dependent on the property that is associated with it. The update to this ProgressBar has reached the animation effect shown above.

Knowing that, that would be a good idea. We define an additional ListView renderer:

Https://github.com/gruan01/ListViewExtend/blob/master/ListViewExtend/ListViewExtend.WinPhone/Renders/ListViewRender.cs

Declare yourself a UIElement object, through this. Children.add (XXX), add it in, and then animate the object in its own event handler to play and stop.

1 protected Override voidOnelementchanged (elementchangedeventargs<xamarin.forms.listview>e) {2     Base. Onelementchanged (e);3     ...4     ...5      This. GRID.CHILDREN.ADD ( This. Viewbox);6      This. Viewbox.child = This. Border;7      This. Children.add ( This. Grid);8     ...9      This. SB =NewSA. Storyboard () {TenDuration =NewDuration (Timespan.frommilliseconds ( +)), OneAutoReverse =true, ARepeatBehavior =SA. Repeatbehavior.forever -     }; -     ... the     ... -      This. Overrideevents (); -}

        Private void updateisrefreshing () {            this. Element.isrefreshing? System.Windows.Visibility.Visible:System.Windows.Visibility.Collapsed;             if (this.) element.isrefreshing)                this. SB. Begin ();             Else                 This . SB. Stop ();        }

The code is simple, the rest is not in the repeating.

Animation effect ugly Point, only for reference.

In addition, the anti-compilation of Android Listviewrenderer, its drop-down refresh is through the swiperefreshlayout to achieve.

This control comes with an animated effect. Search, as if it can not rewrite the animation, can only set a few colors .... This is not a good thing to do ...

Xamarin.form drop-down refresh animation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.