如何恢复WP7中已经打开的页面?

发布于 2024-12-04 16:09:03 字数 208 浏览 2 评论 0原文

如何恢复WP7中已经打开的页面?

例如:在 P1 中有两个按钮 A 和 B,当我单击 A 时,它会将我带到 P2,当我返回 P1 并再次单击 A 时,它不起作用。但是当我点击B后,它会进入P3并返回P1并点击A,它可以工作,但按钮B却不能。

据我所知,该页面的一个实例已经在后台运行。但不知道如何在再次单击按钮时恢复该页面。

谁能帮忙解决这里应该做什么?

How to resume a page which is already opened in WP7?

For example : In P1 there are two buttons A and B,when i click A it takes me to P2 and when i come back to P1 and again click A it not working. But after i click B which takes to P3 and come back to P1 and click A its working,but button B is not.

I understand that an instance of that page is already running in the background. But don't know how to resume that page while clicking the button again.

Can anyone help with what should be done here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

2024-12-11 16:09:04

当您通过 SelectionChanged 导航时,需要重置 SelectedIndex

public void SelectionChanged(object sender, SelectionChangedEventArgs e){

    var lb = (ListBox) sender;

    if (lb.SelectedIndex == -1) return;

    //do your logic here
    NavigationService.Navigate(///);

    //reset selected index
    lb.SelectedIndex = -1;

}

编辑:SelectedIndexLongListSelector 中不可用。请改用SelectedItem

void PersonSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (buddies.SelectedItem == null) return;
            Person person = buddies.SelectedItem as Person;
            if (person != null)
            {
                NavigationService.Navigate(new Uri("/Samples/PersonDetail.xaml?ID=" + person.ID, UriKind.Relative));
            }

            buddies.SelectedItem = null;
        }

When you are navigating via SelectionChanged, you need to reset the SelectedIndex:

public void SelectionChanged(object sender, SelectionChangedEventArgs e){

    var lb = (ListBox) sender;

    if (lb.SelectedIndex == -1) return;

    //do your logic here
    NavigationService.Navigate(///);

    //reset selected index
    lb.SelectedIndex = -1;

}

Edit: SelectedIndex is not available in LongListSelector. Use SelectedItem instead.

void PersonSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (buddies.SelectedItem == null) return;
            Person person = buddies.SelectedItem as Person;
            if (person != null)
            {
                NavigationService.Navigate(new Uri("/Samples/PersonDetail.xaml?ID=" + person.ID, UriKind.Relative));
            }

            buddies.SelectedItem = null;
        }
油饼 2024-12-11 16:09:04

则用于导航到 P2。

NavigationService.Navigate(new Uri("/P2.xaml", UriKind.Relative));

假定 P2.xaml 是您的 P2 页面,

Use

NavigationService.Navigate(new Uri("/P2.xaml", UriKind.Relative));

to navigate to P2 given that P2.xaml is your P2 page.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文