Search code examples
c#windows-runtimewindows-store-appscontrolspushpin

Navigation from OnDoubleTapped method


I've created a customized Pushpin ( Windows store) and i need to navigate whenever the control double tapped/clicked

So i figured out that OnDoubleTapped(DoubleTappedRoutedEventArgs e) will do it,but when i tried .. it didn't work. The following code is from the Control code-behind

protected async override void OnDoubleTapped(DoubleTappedRoutedEventArgs e)
        {
            base.OnDoubleTapped(e);
            Frame.Navigate(typeof(Target)); //Frame has no Navigate()
        }

Solution

  • This can be solved using a dispatcher :

    Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, new DispatchedHandler(() =>
                {
                    Frame thisFrame = Window.Current.Content as Frame;
                    Window.Current.Activate();
                    thisFrame.Navigate(typeof(Target));
                }));