public void fromTable_Teacher() { //从Selection页面获取静态数据 if (Selection.arg == "fromInfo") //从学生信息表中查询数据 { //跳转页面,传递参数 StudentInfo si = new StudentInfo(); si.Getstring(arg); this.NavigationService.Navigate(si); } else if (Selection.arg == "fromAch") { //跳转页面,传递参数 StudentAchievement sa = new StudentAchievement(); sa.Getstring(arg); this.NavigationService.Navigate(sa); } else if (Selection.arg == "fromFile") { //跳转页面,传递参数 StudentFile sf = new StudentFile(); sf.Getstring(arg); this.NavigationService.Navigate(sf); } }
private void listBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { //获取数据模板中元素的值 Table tl = listBox.SelectedItem as Table; ListBox ls = sender as ListBox; ListBoxItem lstitem = ls.ItemContainerGenerator.ContainerFromItem(ls.SelectedItem) as ListBoxItem; var m = ((学生学籍管理系统.查询结果存储表)(lstitem.Content)).学号; MainWindow.num = m; if (Selection.arg == "fromInfo") { StudentInfo si = new StudentInfo(); //第一次初始化,StudentInfo中的Getstring()方法并未被赋值 si.Getstring(m); //所以需要第二次初始化,以得到正确结果 StudentInfo si1 = new StudentInfo(); this.NavigationService.Navigate(si1); } else if (Selection.arg == "fromAch") { StudentAchievement sa = new StudentAchievement(); sa.Getstring(m); StudentAchievement sa1 = new StudentAchievement(); this.NavigationService.Navigate(sa1); } else if (Selection.arg == "fromFile") { StudentFile sf = new StudentFile(); sf.Getstring(m); StudentFile sf1 = new StudentFile(); this.NavigationService.Navigate(sf1); } }