积极答复者
页面导航传参问题

问题
答案
-
你好,可以在当前页面中定义一个List字段并设为public,在跳转到第二个页面的时候重写OnNavigatedTo方法,并将其e.Content转换为之前的页面。这样就可以访问到List值了。具体请参考FAQ的第七条
- 已标记为答案 Shi Ding 2012年3月13日 6:33
2012年3月6日 2:12
全部回复
-
你好,可以在当前页面中定义一个List字段并设为public,在跳转到第二个页面的时候重写OnNavigatedTo方法,并将其e.Content转换为之前的页面。这样就可以访问到List值了。具体请参考FAQ的第七条
- 已标记为答案 Shi Ding 2012年3月13日 6:33
2012年3月6日 2:12 -
按你提供的第三种方法进行共享数据发现不行;
在MainPivotPage中触发listbox的select 事件进行页面跳转到PropertyDetailPage页面;
在MainpivotPage中定义了
public MainViewModel vm;
public MainPivotPage()
{
InitializeComponent();
vm = new MainViewModel();
PropertyList.Loaded +=new RoutedEventHandler(PropertyList_Loaded);
PropertyList.PropertyListBox.SelectionChanged +=new SelectionChangedEventHandler(PropertyListBox_SelectionChanged);
CommunityList.Loaded +=new RoutedEventHandler(CommunityList_Loaded);
CommunityList.CommunityListBox.SelectionChanged += new SelectionChangedEventHandler(CommunityListBox_SelectionChanged);
}NavigationService.Navigate(new Uri("/PropertyDetailPage.xaml?item="+((ListBox)sender).SelectedIndex.ToString(), UriKind.Relative));
在PropertyDetailPage重写了
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
if (e.Content is MainPivotPage)
{
vm = (e.Content as MainPivotPage).vm.Properties[int.Parse(NavigationContext.QueryString["item"])];
DataContext = vm;
}
}if语句中根本都不走的,查看e.Content是PropertyDetailPage
我的使用哪里有错吗?
2012年6月2日 14:21