Created
May 4, 2012 18:36
-
-
Save germboy/2596814 to your computer and use it in GitHub Desktop.
MainPage file for disabling WP7 pinch/zoom & scroll-snapback
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Net; | |
using System.Windows; | |
using System.Windows.Controls; | |
using System.Windows.Documents; | |
using System.Windows.Input; | |
using System.Windows.Media; | |
using System.Windows.Media.Animation; | |
using System.Windows.Shapes; | |
using Microsoft.Phone.Controls; | |
using System.IO; | |
using System.Windows.Media.Imaging; | |
using System.Windows.Resources; | |
using App.Util; | |
namespace App | |
{ | |
public partial class MainPage : PhoneApplicationPage | |
{ | |
private WebBrowserHelper _browserHelper; | |
// Constructor | |
public MainPage() | |
{ | |
InitializeComponent(); | |
this.PGView.Loaded += GapBrowser_Loaded; | |
_browserHelper = new WebBrowserHelper(PGView.Browser); | |
this.PGView.Browser.ScriptNotify += Browser_ScriptNotify; | |
} | |
private void GapBrowser_Loaded(object sender, RoutedEventArgs e) | |
{ | |
this.PGView.Loaded -= GapBrowser_Loaded; | |
Storyboard _storyBoard = new Storyboard(); | |
DoubleAnimation animation = new DoubleAnimation() | |
{ | |
From = 0, | |
Duration = TimeSpan.FromSeconds(0.6), | |
To = 90 | |
}; | |
Storyboard.SetTarget(animation, SplashProjector); | |
Storyboard.SetTargetProperty(animation, new PropertyPath("RotationY")); | |
_storyBoard.Children.Add(animation); | |
_storyBoard.Begin(); | |
_storyBoard.Completed += Splash_Completed; | |
} | |
void Splash_Completed(object sender, EventArgs e) | |
{ | |
(sender as Storyboard).Completed -= Splash_Completed; | |
LayoutRoot.Children.Remove(SplashImage); | |
} | |
private void Browser_ScriptNotify(object sender, NotifyEventArgs e) | |
{ | |
// if a page notifies that it should not be scrollable, disable | |
// scrolling. | |
if (e.Value == "noScroll") | |
{ | |
_browserHelper.ScrollDisabled = true; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment