开发者

Pause WP7 HyperlinkButton?

I'm trying to 'pause' a HyperlinkButton in a WP7 app so that the user can confirm whether or not to leave the app and follow the link. The series of the events would look like:

  1. The user clicks the HyperlinkButton
  2. MessageBox pops up to confirm they want to leave the app and visit this external site
  3. If the user agrees, the webpage loads; if not, the user is returned to the app

M开发者_运维百科y question is: can I get HyperlinkButton to wait for the user's response?

At the moment, I've hacked a solution as below:

<HyperlinkButton Tag="http://www.google.com/" Tap="ConfirmBeforeLoading()"/>

ConfirmBeforeLoading then prompts the user and, if they agree, it creates a new WebBrowserTask using the address in the Tag property.

This works, but it seems 'hackish'. Is there any way I can use a normal HyperlinkButton with NavigateUri and just have it wait for the user's response?

Many thanks in advance!


try this one,maybe helpfull to you,

    Popup mypopup;   //golbal variable

    private void hyperlinkButton1_Click(object sender, RoutedEventArgs e)

    {
        LayoutRoot.Opacity = 0.6;
        mypopup = new Popup();
        Border border = new Border();
        StackPanel st = new StackPanel();

        TextBlock tb = new TextBlock();
        tb.Text = "Visit website";
        tb.FontSize = 24;

        Button btnok = new Button();
        btnok.Content = "Ok";
        btnok.Click += new RoutedEventHandler(btnok_Click);
        Button btncancel = new Button();
        btncancel.Content = "Cancel";
        btncancel.Click += new RoutedEventHandler(btncancel_Click);

        st1.Orientation = System.Windows.Controls.Orientation.Horizontal;
        st1.Children.Add(btnok);
        st1.Children.Add(btncancel);

        st.Children.Add(tb);
        st.Children.Add(st1); 

        border.Child = st;
        mypopup.VerticalOffset = 25;
        mypopup.HorizontalOffset = 25;
        mypopup.Margin = new Thickness(LayoutRoot.ActualWidth / 4, LayoutRoot.ActualHeight / 3, 0, 0);
        mypopup.Child = border;
        mypopup.IsOpen = true;
    }


    void btncancel_Click(object sender, RoutedEventArgs e)

    {
        LayoutRoot.Opacity = 1;
        mypopup.IsOpen = false;
    }

    void btnok_Click(object sender, RoutedEventArgs e)

    {
        //here what do you want....
    }

its work for me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜