welcome to Qijie's Blog 薛其杰
        Accelerometer _accelerometer;
        int _shakeCount = 0;
        public MainPage()
        {
            this.InitializeComponent();
            _accelerometer=Accelerometer.GetDefault();
            if (_accelerometer != null)
                _accelerometer.Shaken += new TypedEventHandler<Accelerometer, AccelerometerShakenEventArgs>(Shaken);
        }

        async private void Shaken(object sender, AccelerometerShakenEventArgs e)
        {
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                _shakeCount++;
            });

            if (_shakeCount >= 3)
            {
                //method call
                _shakeCount = 0;
            }
        }


Don't know if it works?

posted on 2013-09-24 16:22  零点零一  阅读(197)  评论(0编辑  收藏  举报