Windows phone 8 在windows phone 8中将所选内容从LonglistSelector返回到呼叫页面

Windows phone 8 在windows phone 8中将所选内容从LonglistSelector返回到呼叫页面,windows-phone-8,longlistselector,Windows Phone 8,Longlistselector,我有一个带有一些内容的按钮的主页。我想打开第二页或弹出窗口,我必须有一个长列表选择器,其中有X个项目。当我选择其中一个时,我想将按钮的内容更改为所选项目 我可以制作主页和第二页,但我不知道如何将结果发送回第一页 如果您使用的是MVVM Light library,那么您可以像这样使用Messenger service 在选择更改后的第二页中发送消息 Messenger.Default.Send<type>(message,token); 使用Popup显示您的LongListSel

我有一个带有一些内容的按钮的主页。我想打开第二页或弹出窗口,我必须有一个长列表选择器,其中有X个项目。当我选择其中一个时,我想将按钮的内容更改为所选项目


我可以制作主页和第二页,但我不知道如何将结果发送回第一页

如果您使用的是MVVM Light library,那么您可以像这样使用Messenger service

在选择更改后的第二页中发送消息

Messenger.Default.Send<type>(message,token);

使用Popup显示您的LongListSelector,当设置popupElement.IsOpen=false时;设置按钮内容与要求相同

如果您希望将内容更改为所选列表,请使用popupElement.IsOpen=false;在选择上更改方法并在其中获取所选项目


记住在页面上使用选择更改方法,而不是在弹出子类中

如果您使用单独的页面来显示longlistselector,那么您可以尝试以下方法

//in long list page, 
Void longlist_SelectionChanged()
{
    PhoneApplicationService.Current.State["key"] = longlist.selecteditem;
    NavigationService.GoBack();
}

//in your main page where the selected data has to be displayed..
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
    if(PhoneApplicationService.Current.State.ContainsKey("key"))
    {
        Button.Content = PhoneApplicationService.Current.State["key"];
    }
}
void Method(type message)
{
  button.content = message;
}
//in long list page, 
Void longlist_SelectionChanged()
{
    PhoneApplicationService.Current.State["key"] = longlist.selecteditem;
    NavigationService.GoBack();
}

//in your main page where the selected data has to be displayed..
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
    if(PhoneApplicationService.Current.State.ContainsKey("key"))
    {
        Button.Content = PhoneApplicationService.Current.State["key"];
    }
}