Scenario 1: Using Panorama or pivotpage
1. Rewrite the Panorama page so that it reaches full screen
public class Panoramafullscreen:panorama { protected override System.Windows.Size MeasureOverride ( System.Windows.Size availablesize) { availablesize.width + =; Return base. MeasureOverride (availablesize); } }
2. Remove the title and header and adjust the margin
<phone:PanoramaItem> <grid canvas.zindex= "-1" margin= " -66,-40,-55,0" verticalalignment= "Stretch" Horizontalalignment= "Stretch" width= "591" > <image stretch= "Fill" source= "/images/screen1.jpg" VerticalAlignment = "Stretch" horizontalalignment= "Stretch" margin= "54,0,54,0"/> </Grid> </phone:PanoramaItem>
3. Control page jump in Codebehind
Private TouchPoint first; Private Const int detectrightgesture = 20; private int startIndex = 0; private ReadOnly int endIndex; Public Whatsnewview () {InitializeComponent (); EndIndex = mystartscreen.items.count-1; Mystartscreen.ishittestvisible = false; mystartscreen.isenabled = false; touch.framereported + = touch_framereported; Touchpanel.enabledgestures = Gesturetype.horizontaldrag; private void Touch_framereported (object sender, Touchframeeventargs e) {try {TouchPoint Maintouch = E.getprimarytouchpoint (this); if (maintouch.action = = touchaction.down) first = Maintouch; else if (maintouch.action = = Touchaction.up && touchpanel.isgestureavailable) { if (Maintouch.position.x-first. Position.x <-detectrightgesture) {if (StartIndex < EndIndex) { Mystartscreen.slidetopage (StartIndex + 1, slidetransitionmode.slideleftfadeout); startindex++; } else {navigatetonextpage (); }} else if (Maintouch.position.x-first. position.x > Detectrightgesture) {if (StartIndex > 0) {Mystartscreen.slidetopage (startIndex-1, slidetransitionmode.sliderightfadeout); startindex--; }}}} "catch {}}" private Vo ID Buttonbase_onclick (object sender, RoutedEventArgs e) {navigatetonextpage (); } private void Navigatetonextpage () {navigationservice.navigate (The new Uri ("/views/loginpage.xaml ", urikind.relative)); } protected override void Onnavigatedfrom (NavigationEventArgs e) {while (navigationservice.backs Tack. Any ()) {navigationservice.removebackentry (); } }
4. Add: Expand the Panorama method so that it jumps with the animation
public static void Slidetopage (this Panorama self, int item, Slidetransitionmode slidemode) { var Slidetransition = new Slidetransition {}; Slidetransition.mode = Slidemode; Itransition transition = slidetransition.gettransition (self); transition.completed + = delegate {self . Defaultitem = self. Items[item]; Transition. Stop (); }; Transition. Begin (); }
Insufficient:
Slidetransitionmode Slidetransitionmode Support Animation is limited, generally do not achieve the desired effect
Scenario 2:
Arranges all the pictures horizontally and controls the display by the left and right offsets according to the gesture
<Canvas> <stackpanel x:name= "Slider" canvas.left= "0" orientation= "Horizontal" > < Image source= "/images/screen1.jpg" Stretch = "UniformToFill"/> <image source= "/images/screen2.jpg" Stretch = "UniformToFill"/> <image source= "/images/screen3.jpg" Stretch = "UniformToFill"/> </StackPanel> </Canvas>
In general, the buttons on the last page are different from the previous one and can be distinguished by slidepageindex. Declare it as a dependency property and control whether the display is displayed by converter in the view
public static readonly DependencyProperty slidepageindexproperty = dependencyproperty.register ("Slidepageindex" , typeof (int), typeof (Startscreenview), null); public int Slidepageindex { get {return (int) GetValue (slidepageindexproperty);} set {SetValue (Slidepageindexproperty, value);} }
Offsets based on different devices
_uniformimagewidth = (int) Application.Current.Host.Content.ActualWidth;
Gesture Control
touch.framereported + = touch_framereported; Touchpanel.enabledgestures = Gesturetype.horizontaldrag;
private void Touch_framereported (object sender, Touchframeeventargs e) {try { TouchPoint Maintouch = E.getprimarytouchpoint (this); if (maintouch.action = = touchaction.down) first = Maintouch; else if (maintouch.action = = Touchaction.up && touchpanel.isgestureavailable) { if (Maintouch.position.x-first. Position.x <-detectrightgesture) {if (Slidepageindex = = Maxslidepagecount- 1) {navigatetologinpage (); } slidepageindex++; Slide (); } else if (Maintouch.position.x-first. position.x > Detectrightgesture) {if (Slidepageindex = = 0) return; slidepageindex--; SlidE (); }}}, catch {}}
Sliding logic
private void Slide () { var storyboard = new Storyboard (); var ani = new DoubleAnimation (); Ani. to = Slidepageindex *-_uniformimagewidth; Ani. Duration = Timespan.fromseconds (1.0f); Ani. Easingfunction = new Elasticease () {Easingmode = easingmode.easeinout, oscillations = 0}; Storyboard.settarget (ANI, this.) Slider); Storyboard.settargetproperty (ANI, New PropertyPath ("(Canvas.Left)")); Storyboard. Children.add (ANI); Storyboard. Begin (); }
This page cannot be navigated by the back key
protected override void Onnavigatedfrom (NavigationEventArgs e) {while (NavigationService.BackStack.Any ()) { navigationservice.removebackentry (); } }
Windows Phone app Add launch page introducing new features